MediaWiki
REL1_35
benchmarkStringReplacement.php
Go to the documentation of this file.
1
<?php
22
require_once __DIR__ .
'/../includes/Benchmarker.php'
;
23
29
class
BenchmarkStringReplacement
extends
Benchmarker
{
30
protected
$defaultCount
= 10000;
31
private
$input
=
'MediaWiki:Some_random_test_page'
;
32
33
public
function
__construct
() {
34
parent::__construct();
35
$this->
addDescription
(
'Benchmark for string replacement methods.'
);
36
}
37
38
public
function
execute
() {
39
$this->
bench
( [
40
'strtr'
=> [ $this,
'bench_strtr'
],
41
'str_replace'
=> [ $this,
'bench_str_replace'
],
42
] );
43
}
44
45
protected
function
bench_strtr
() {
46
strtr( $this->input,
"_"
,
" "
);
47
}
48
49
protected
function
bench_str_replace
() {
50
str_replace(
"_"
,
" "
, $this->input );
51
}
52
}
53
54
$maintClass
= BenchmarkStringReplacement::class;
55
require_once
RUN_MAINTENANCE_IF_MAIN
;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition
Maintenance.php:38
$maintClass
$maintClass
Definition
benchmarkStringReplacement.php:54
BenchmarkStringReplacement
Maintenance script that benchmarks string replacement methods.
Definition
benchmarkStringReplacement.php:29
BenchmarkStringReplacement\bench_strtr
bench_strtr()
Definition
benchmarkStringReplacement.php:45
BenchmarkStringReplacement\bench_str_replace
bench_str_replace()
Definition
benchmarkStringReplacement.php:49
BenchmarkStringReplacement\__construct
__construct()
Default constructor.
Definition
benchmarkStringReplacement.php:33
BenchmarkStringReplacement\$defaultCount
$defaultCount
Definition
benchmarkStringReplacement.php:30
BenchmarkStringReplacement\$input
$input
Definition
benchmarkStringReplacement.php:31
BenchmarkStringReplacement\execute
execute()
Do the actual work.
Definition
benchmarkStringReplacement.php:38
Benchmarker
Base class for benchmark scripts.
Definition
Benchmarker.php:41
Benchmarker\bench
bench(array $benchs)
Definition
Benchmarker.php:51
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:325
maintenance
benchmarks
benchmarkStringReplacement.php
Generated on Sat Apr 6 2024 00:08:22 for MediaWiki by
1.9.8