- global $wgHooks;
- $wgHooks['Test'] = [];
-
- $time = $this->benchHooks();
- $this->output( 'Empty hook: ' . $time . "\n" );
-
- $wgHooks['Test'][] = [ $this, 'test' ];
- $time = $this->benchHooks();
- $this->output( 'Loaded (one) hook: ' . $time . "\n" );
-
- for ( $i = 0; $i < 9; $i++ ) {
- $wgHooks['Test'][] = [ $this, 'test' ];
- }
- $time = $this->benchHooks();
- $this->output( 'Loaded (ten) hook: ' . $time . "\n" );
-
- for ( $i = 0; $i < 90; $i++ ) {
- $wgHooks['Test'][] = [ $this, 'test' ];
+ $cases = [
+ 'Loaded 0 hooks' => 0,
+ 'Loaded 1 hook' => 1,
+ 'Loaded 10 hooks' => 10,
+ 'Loaded 100 hooks' => 100,
+ ];
+ $benches = [];
+ foreach ( $cases as $label => $load ) {
+ $benches[$label] = [
+ 'setup' => function () use ( $load ) {
+ global $wgHooks;
+ $wgHooks['Test'] = [];
+ for ( $i = 1; $i <= $load; $i++ ) {
+ $wgHooks['Test'][] = [ $this, 'test' ];
+ }
+ },
+ 'function' => function () {
+ Hooks::run( 'Test' );
+ }
+ ];