MediaWiki
REL1_34
benchmarkStringReplacement.php
Go to the documentation of this file.
1
<?php
22
require_once __DIR__ .
'/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:39
$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:40
Benchmarker\bench
bench(array $benchs)
Definition
Benchmarker.php:50
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:348
maintenance
benchmarks
benchmarkStringReplacement.php
Generated on Fri Apr 5 2024 23:11:05 for MediaWiki by
1.9.8