From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- maintenance/benchmarks/benchmarkHooks.php | 80 +++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 maintenance/benchmarks/benchmarkHooks.php (limited to 'maintenance/benchmarks/benchmarkHooks.php') diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php new file mode 100644 index 00000000..4ec26168 --- /dev/null +++ b/maintenance/benchmarks/benchmarkHooks.php @@ -0,0 +1,80 @@ +mDescription = 'Benchmark MediaWiki Hooks.'; + } + + public function execute() { + global $wgHooks; + $wgHooks['Test'] = array(); + + $time = $this->benchHooks(); + $this->output( 'Empty hook: ' . $time . "\n" ); + + $wgHooks['Test'][] = array( $this, 'test' ); + $time = $this->benchHooks(); + $this->output( 'Loaded (one) hook: ' . $time . "\n" ); + + for( $i = 0; $i < 9; $i++ ) { + $wgHooks['Test'][] = array( $this, 'test' ); + } + $time = $this->benchHooks(); + $this->output( 'Loaded (ten) hook: ' . $time . "\n" ); + + for( $i = 0; $i < 90; $i++ ) { + $wgHooks['Test'][] = array( $this, 'test' ); + } + $time = $this->benchHooks(); + $this->output( 'Loaded (one hundred) hook: ' . $time . "\n" ); + $this->output( "\n" ); + } + + /** + * @param $trials int + * @return string + */ + private function benchHooks( $trials = 10 ) { + $start = wfTime(); + for ( $i = 0; $i < $trials; $i++ ) { + wfRunHooks( 'Test' ); + } + $delta = wfTime() - $start; + $pertrial = $delta / $trials; + return sprintf( "Took %6.2fs", + $pertrial ); + } + + /** + * @return bool + */ + public function test() { + return true; + } +} + +$maintClass = 'BenchmarkHooks'; +require_once( RUN_MAINTENANCE_IF_MAIN ); -- cgit v1.2.3-54-g00ecf