UDP profiling
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 19 Nov 2006 03:56:54 +0000 (03:56 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 19 Nov 2006 03:56:54 +0000 (03:56 +0000)
maintenance/dumpHTML.inc

index 86f675c..702c7df 100644 (file)
@@ -70,6 +70,9 @@ class DumpHTML {
        # Max page ID, lazy initialised
        var $maxPageID = false;
 
+       # UDP profiling
+       var $udpProfile, $udpProfileCounter = 0, $udpProfileInit = false;
+
        function DumpHTML( $settings = array() ) {
                foreach ( $settings as $var => $value ) {
                        $this->$var = $value;
@@ -450,6 +453,8 @@ class DumpHTML {
                        }
                }
 
+               $this->profile();
+
                $this->rawPages = array();
                $text = $this->getArticleHTML( $title );
 
@@ -958,7 +963,33 @@ ENDTEXT;
                }
                return $this->maxPageID;
        }
-                       
+
+       function profile() {
+               global $wgProfiler;
+
+               if ( !$this->udpProfile ) {
+                       return;
+               }
+               if ( !$this->udpProfileInit ) {
+                       $this->udpProfileInit = true;
+               } elseif ( $this->udpProfileCounter == 1 % $this->udpProfile ) {
+                       $wgProfiler->getFunctionReport();
+                       $wgProfiler = new DumpHTML_ProfilerStub;
+               }
+               if ( $this->udpProfileCounter == 0 ) {
+                       $wgProfiler = new ProfilerSimpleUDP;
+                       $wgProfiler->setProfileID( 'dumpHTML' );
+               }
+               $this->udpProfileCounter = ( $this->udpProfileCounter + 1 ) % $this->udpProfile;
+       }
+}
+
+class DumpHTML_ProfilerStub {
+       function profileIn() {}
+       function profileOut() {}
+       function getOutput() {}
+       function close() {}
+       function getFunctionReport() {}
 }
 
 /** XML parser callback */