MediaWiki  1.23.2
benchmarkHooks.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Benchmarker.php';
25 
31 class BenchmarkHooks extends Benchmarker {
32 
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = 'Benchmark MediaWiki Hooks.';
36  }
37 
38  public function execute() {
40  $wgHooks['Test'] = array();
41 
42  $time = $this->benchHooks();
43  $this->output( 'Empty hook: ' . $time . "\n" );
44 
45  $wgHooks['Test'][] = array( $this, 'test' );
46  $time = $this->benchHooks();
47  $this->output( 'Loaded (one) hook: ' . $time . "\n" );
48 
49  for( $i = 0; $i < 9; $i++ ) {
50  $wgHooks['Test'][] = array( $this, 'test' );
51  }
52  $time = $this->benchHooks();
53  $this->output( 'Loaded (ten) hook: ' . $time . "\n" );
54 
55  for( $i = 0; $i < 90; $i++ ) {
56  $wgHooks['Test'][] = array( $this, 'test' );
57  }
58  $time = $this->benchHooks();
59  $this->output( 'Loaded (one hundred) hook: ' . $time . "\n" );
60  $this->output( "\n" );
61  }
62 
67  private function benchHooks( $trials = 10 ) {
68  $start = microtime( true );
69  for ( $i = 0; $i < $trials; $i++ ) {
70  wfRunHooks( 'Test' );
71  }
72  $delta = microtime( true ) - $start;
73  $pertrial = $delta / $trials;
74  return sprintf( "Took %6.3fms",
75  $pertrial * 1000 );
76  }
77 
81  public function test() {
82  return true;
83  }
84 }
85 
86 $maintClass = 'BenchmarkHooks';
87 require_once RUN_MAINTENANCE_IF_MAIN;
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
BenchmarkHooks\__construct
__construct()
Default constructor.
Definition: benchmarkHooks.php:33
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4001
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
BenchmarkHooks\test
test()
Definition: benchmarkHooks.php:81
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
BenchmarkHooks\execute
execute()
Do the actual work.
Definition: benchmarkHooks.php:38
BenchmarkHooks
Maintenance script that benchmarks MediaWiki hooks.
Definition: benchmarkHooks.php:31
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
$maintClass
$maintClass
Definition: benchmarkHooks.php:86
BenchmarkHooks\benchHooks
benchHooks( $trials=10)
Definition: benchmarkHooks.php:67