From: Sam Reed Date: Sun, 16 Oct 2011 03:32:39 +0000 (+0000) Subject: svn:eol-style native X-Git-Tag: 1.31.0-rc.0~27071 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=472ce1456fe98b8ff20b1429b8f19e75bfb3e117;p=lhc%2Fweb%2Fwiklou.git svn:eol-style native --- diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php index ec11c2f8bd..d614423bed 100644 --- a/maintenance/benchmarks/benchmarkHooks.php +++ b/maintenance/benchmarks/benchmarkHooks.php @@ -1,80 +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 ); +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 );