From 0af04a048a7e3fe97127c30702f9d93154f92f45 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 19 Nov 2006 03:56:54 +0000 Subject: [PATCH] UDP profiling --- maintenance/dumpHTML.inc | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/maintenance/dumpHTML.inc b/maintenance/dumpHTML.inc index 86f675c250..702c7df901 100644 --- a/maintenance/dumpHTML.inc +++ b/maintenance/dumpHTML.inc @@ -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 */ -- 2.20.1