Index: trunk/phase3/maintenance/dumpHTML.inc |
— | — | @@ -70,6 +70,9 @@ |
71 | 71 | # Max page ID, lazy initialised |
72 | 72 | var $maxPageID = false; |
73 | 73 | |
| 74 | + # UDP profiling |
| 75 | + var $udpProfile, $udpProfileCounter = 0, $udpProfileInit = false; |
| 76 | + |
74 | 77 | function DumpHTML( $settings = array() ) { |
75 | 78 | foreach ( $settings as $var => $value ) { |
76 | 79 | $this->$var = $value; |
— | — | @@ -450,6 +453,8 @@ |
451 | 454 | } |
452 | 455 | } |
453 | 456 | |
| 457 | + $this->profile(); |
| 458 | + |
454 | 459 | $this->rawPages = array(); |
455 | 460 | $text = $this->getArticleHTML( $title ); |
456 | 461 | |
— | — | @@ -958,9 +963,35 @@ |
959 | 964 | } |
960 | 965 | return $this->maxPageID; |
961 | 966 | } |
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 | + } |
963 | 986 | } |
964 | 987 | |
| 988 | +class DumpHTML_ProfilerStub { |
| 989 | + function profileIn() {} |
| 990 | + function profileOut() {} |
| 991 | + function getOutput() {} |
| 992 | + function close() {} |
| 993 | + function getFunctionReport() {} |
| 994 | +} |
| 995 | + |
965 | 996 | /** XML parser callback */ |
966 | 997 | function wfDumpStartTagHandler( $parser, $name, $attribs ) { |
967 | 998 | global $wgDumpImages; |