Add the ability to change the profile ID for UDP profiling at runtime
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 18 Nov 2006 05:17:25 +0000 (05:17 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 18 Nov 2006 05:17:25 +0000 (05:17 +0000)
includes/ProfilerSimple.php
includes/ProfilerSimpleUDP.php

index d5bdaf9..2d0d01b 100644 (file)
@@ -12,6 +12,7 @@ require_once(dirname(__FILE__).'/Profiler.php');
 
 class ProfilerSimple extends Profiler {
        var $mMinimumTime = 0;
+       var $mProfileID = false;
 
        function ProfilerSimple() {
                global $wgRequestTime,$wgRUstart;
@@ -39,6 +40,18 @@ class ProfilerSimple extends Profiler {
                $this->mMinimumTime = $min;
        }
 
+       function setProfileID( $id ) {
+               $this->mProfileID = $id;
+       }
+
+       function getProfileID() {
+               if ( $this->mProfileID === false ) {
+                       return wfWikiID();
+               } else {
+                       return $this->mProfileID;
+               }
+       }
+
        function profileIn($functionname) {
                global $wgDebugFunctionEntry;
                if ($wgDebugFunctionEntry) {
index e049051..a8527c3 100644 (file)
@@ -21,7 +21,7 @@ class ProfilerSimpleUDP extends ProfilerSimple {
                $plength=0;
                $packet="";
                foreach ($this->mCollated as $entry=>$pfdata) {
-                       $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", wfWikiID(),"-",$pfdata['count'],
+                       $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", $this->getProfileID(),"-",$pfdata['count'],
                                $pfdata['cpu'],$pfdata['cpu_sq'],$pfdata['real'],$pfdata['real_sq'],$entry);
                        $length=strlen($pfline);
                        /* printf("<!-- $pfline -->"); */