X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Fbenchmarks%2FbenchmarkHooks.php;h=144687191d9053eeb65cb30bac9151ec1d0d2ade;hb=44cebea941236e165bf55e80565d6679529c7280;hp=3f5d6db0d97726f22a07b739c9781f85556831b6;hpb=f10c9815e69b59844c178d218640bd1ac0435896;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php index 3f5d6db0d9..144687191d 100644 --- a/maintenance/benchmarks/benchmarkHooks.php +++ b/maintenance/benchmarks/benchmarkHooks.php @@ -29,7 +29,6 @@ require_once __DIR__ . '/Benchmarker.php'; * @ingroup Benchmark */ class BenchmarkHooks extends Benchmarker { - public function __construct() { parent::__construct(); $this->mDescription = 'Benchmark MediaWiki Hooks.'; @@ -46,13 +45,13 @@ class BenchmarkHooks extends Benchmarker { $time = $this->benchHooks(); $this->output( 'Loaded (one) hook: ' . $time . "\n" ); - for( $i = 0; $i < 9; $i++ ) { + 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++ ) { + for ( $i = 0; $i < 90; $i++ ) { $wgHooks['Test'][] = array( $this, 'test' ); } $time = $this->benchHooks(); @@ -61,16 +60,17 @@ class BenchmarkHooks extends Benchmarker { } /** - * @param $trials int + * @param int $trials * @return string */ private function benchHooks( $trials = 10 ) { $start = microtime( true ); for ( $i = 0; $i < $trials; $i++ ) { - wfRunHooks( 'Test' ); + Hooks::run( 'Test' ); } $delta = microtime( true ) - $start; $pertrial = $delta / $trials; + return sprintf( "Took %6.3fms", $pertrial * 1000 ); }