r17795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17794‎ | r17795 | r17796 >
Date:03:56, 19 November 2006
Author:tstarling
Status:old
Tags:
Comment:
UDP profiling
Modified paths:
  • /trunk/phase3/maintenance/dumpHTML.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/dumpHTML.inc
@@ -70,6 +70,9 @@
7171 # Max page ID, lazy initialised
7272 var $maxPageID = false;
7373
 74+ # UDP profiling
 75+ var $udpProfile, $udpProfileCounter = 0, $udpProfileInit = false;
 76+
7477 function DumpHTML( $settings = array() ) {
7578 foreach ( $settings as $var => $value ) {
7679 $this->$var = $value;
@@ -450,6 +453,8 @@
451454 }
452455 }
453456
 457+ $this->profile();
 458+
454459 $this->rawPages = array();
455460 $text = $this->getArticleHTML( $title );
456461
@@ -958,9 +963,35 @@
959964 }
960965 return $this->maxPageID;
961966 }
962 -
 967+
 968+ function profile() {
 969+ global $wgProfiler;
 970+
 971+ if ( !$this->udpProfile ) {
 972+ return;
 973+ }
 974+ if ( !$this->udpProfileInit ) {
 975+ $this->udpProfileInit = true;
 976+ } elseif ( $this->udpProfileCounter == 1 % $this->udpProfile ) {
 977+ $wgProfiler->getFunctionReport();
 978+ $wgProfiler = new DumpHTML_ProfilerStub;
 979+ }
 980+ if ( $this->udpProfileCounter == 0 ) {
 981+ $wgProfiler = new ProfilerSimpleUDP;
 982+ $wgProfiler->setProfileID( 'dumpHTML' );
 983+ }
 984+ $this->udpProfileCounter = ( $this->udpProfileCounter + 1 ) % $this->udpProfile;
 985+ }
963986 }
964987
 988+class DumpHTML_ProfilerStub {
 989+ function profileIn() {}
 990+ function profileOut() {}
 991+ function getOutput() {}
 992+ function close() {}
 993+ function getFunctionReport() {}
 994+}
 995+
965996 /** XML parser callback */
966997 function wfDumpStartTagHandler( $parser, $name, $attribs ) {
967998 global $wgDumpImages;