MediaWiki
master
benchmarkHooks.php
Go to the documentation of this file.
1
<?php
24
// @codeCoverageIgnoreStart
25
require_once __DIR__ .
'/../includes/Benchmarker.php'
;
26
// @codeCoverageIgnoreEnd
27
33
class
BenchmarkHooks
extends
Benchmarker
{
34
protected
$defaultCount
= 10;
35
36
public
function
__construct
() {
37
parent::__construct();
38
$this->
addDescription
(
'Benchmark MediaWiki Hooks.'
);
39
}
40
41
public
function
execute
() {
42
$cases = [
43
'Loaded 0 hooks'
=> 0,
44
'Loaded 1 hook'
=> 1,
45
'Loaded 10 hooks'
=> 10,
46
'Loaded 100 hooks'
=> 100,
47
];
48
$benches = [];
49
$hookContainer = $this->
getHookContainer
();
50
foreach
( $cases as $label => $load ) {
51
$benches[$label] = [
52
'setup'
=>
function
() use ( $load, $hookContainer ) {
53
for
( $i = 1; $i <= $load; $i++ ) {
54
$hookContainer->register(
'Test'
, [ $this,
'test'
] );
55
}
56
},
57
'function'
=>
static
function
() use ( $hookContainer ) {
58
$hookContainer->run(
'Test'
);
59
}
60
];
61
}
62
$this->
bench
( $benches );
63
}
64
68
public
function
test
() {
69
return
true
;
70
}
71
}
72
73
// @codeCoverageIgnoreStart
74
$maintClass
= BenchmarkHooks::class;
75
require_once RUN_MAINTENANCE_IF_MAIN;
76
// @codeCoverageIgnoreEnd
$maintClass
$maintClass
Definition
benchmarkHooks.php:74
BenchmarkHooks
Maintenance script that benchmarks MediaWiki hooks.
Definition
benchmarkHooks.php:33
BenchmarkHooks\__construct
__construct()
Default constructor.
Definition
benchmarkHooks.php:36
BenchmarkHooks\execute
execute()
Do the actual work.
Definition
benchmarkHooks.php:41
BenchmarkHooks\test
test()
Definition
benchmarkHooks.php:68
BenchmarkHooks\$defaultCount
$defaultCount
Definition
benchmarkHooks.php:34
Benchmarker
Base class for benchmark scripts.
Definition
Benchmarker.php:40
Benchmarker\bench
bench(array $benchs)
Definition
Benchmarker.php:49
Maintenance\getHookContainer
getHookContainer()
Get a HookContainer, for running extension hooks or for hook metadata.
Definition
Maintenance.php:1402
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:331
maintenance
benchmarks
benchmarkHooks.php
Generated on Sat Sep 7 2024 14:26:28 for MediaWiki by
1.10.0