Index: trunk/phase3/maintenance/benchmarks/benchmarkHooks.php |
— | — | @@ -29,31 +29,25 @@ |
30 | 30 | }
|
31 | 31 |
|
32 | 32 | public function execute() {
|
33 | | - $time = $this->benchEmptyHooks();
|
34 | | - $this->output( 'Empty hook: ' . $time . "\n" );
|
35 | | - $time = $this->benchLoadedHooks();
|
36 | | - $this->output( 'Loaded hook: ' . $time . "\n" );
|
37 | | - $this->output( "\n" );
|
38 | | - }
|
39 | | -
|
40 | | - private function benchEmptyHooks( $trials = 1 ) {
|
41 | 33 | global $wgHooks;
|
42 | 34 | $wgHooks['Test'] = array();
|
43 | 35 |
|
44 | | - $start = wfTime();
|
45 | | - for ( $i = 0; $i < $trials; $i++ ) {
|
46 | | - wfRunHooks( 'Test' );
|
47 | | - }
|
48 | | - $delta = wfTime() - $start;
|
49 | | - $pertrial = $delta / $trials;
|
50 | | - return sprintf( "Took %6.2fms",
|
51 | | - $pertrial );
|
52 | | - }
|
| 36 | + $time = $this->benchHooks();
|
| 37 | + $this->output( 'Empty hook: ' . $time . "\n" );
|
53 | 38 |
|
54 | | - private function benchLoadedHooks( $trials = 1 ) {
|
55 | | - global $wgHooks;
|
56 | 39 | $wgHooks['Test'][] = array( $this, 'test' );
|
| 40 | + $time = $this->benchHooks();
|
| 41 | + $this->output( 'Loaded (one) hook: ' . $time . "\n" );
|
57 | 42 |
|
| 43 | + for( $i = 0; $i < 9; $i++ ) {
|
| 44 | + $wgHooks['Test'][] = array( $this, 'test' );
|
| 45 | + }
|
| 46 | + $time = $this->benchHooks();
|
| 47 | + $this->output( 'Loaded (ten) hook: ' . $time . "\n" );
|
| 48 | + $this->output( "\n" );
|
| 49 | + }
|
| 50 | +
|
| 51 | + private function benchHooks( $trials = 1 ) {
|
58 | 52 | $start = wfTime();
|
59 | 53 | for ( $i = 0; $i < $trials; $i++ ) {
|
60 | 54 | wfRunHooks( 'Test' );
|