MediaWiki
REL1_31
bench_strtr_str_replace.php
Go to the documentation of this file.
1
<?php
26
require_once __DIR__ .
'/Benchmarker.php'
;
27
28
function
bfNormalizeTitleStrTr
( $str ) {
29
return
strtr( $str,
'_'
,
' '
);
30
}
31
32
function
bfNormalizeTitleStrReplace
( $str ) {
33
return
str_replace(
'_'
,
' '
, $str );
34
}
35
41
class
BenchStrtrStrReplace
extends
Benchmarker
{
42
public
function
__construct
() {
43
parent::__construct();
44
$this->
addDescription
(
'Benchmark for strtr() vs str_replace().'
);
45
}
46
47
public
function
execute
() {
48
$this->
bench
( [
49
[
'function'
=> [ $this,
'benchstrtr'
] ],
50
[
'function'
=> [ $this,
'benchstr_replace'
] ],
51
[
'function'
=> [ $this,
'benchstrtr_indirect'
] ],
52
[
'function'
=> [ $this,
'benchstr_replace_indirect'
] ],
53
] );
54
}
55
56
protected
function
benchstrtr
() {
57
strtr(
"[[MediaWiki:Some_random_test_page]]"
,
"_"
,
" "
);
58
}
59
60
protected
function
benchstr_replace
() {
61
str_replace(
"_"
,
" "
,
"[[MediaWiki:Some_random_test_page]]"
);
62
}
63
64
protected
function
benchstrtr_indirect
() {
65
bfNormalizeTitleStrTr
(
"[[MediaWiki:Some_random_test_page]]"
);
66
}
67
68
protected
function
benchstr_replace_indirect
() {
69
bfNormalizeTitleStrReplace
(
"[[MediaWiki:Some_random_test_page]]"
);
70
}
71
}
72
73
$maintClass
= BenchStrtrStrReplace::class;
74
require_once
RUN_MAINTENANCE_IF_MAIN
;
$maintClass
$maintClass
Definition
bench_strtr_str_replace.php:73
bfNormalizeTitleStrTr
bfNormalizeTitleStrTr( $str)
Definition
bench_strtr_str_replace.php:28
bfNormalizeTitleStrReplace
bfNormalizeTitleStrReplace( $str)
Definition
bench_strtr_str_replace.php:32
BenchStrtrStrReplace
Maintenance script that benchmarks for strtr() vs str_replace().
Definition
bench_strtr_str_replace.php:41
BenchStrtrStrReplace\benchstrtr_indirect
benchstrtr_indirect()
Definition
bench_strtr_str_replace.php:64
BenchStrtrStrReplace\benchstr_replace_indirect
benchstr_replace_indirect()
Definition
bench_strtr_str_replace.php:68
BenchStrtrStrReplace\__construct
__construct()
Default constructor.
Definition
bench_strtr_str_replace.php:42
BenchStrtrStrReplace\execute
execute()
Do the actual work.
Definition
bench_strtr_str_replace.php:47
BenchStrtrStrReplace\benchstrtr
benchstrtr()
Definition
bench_strtr_str_replace.php:56
BenchStrtrStrReplace\benchstr_replace
benchstr_replace()
Definition
bench_strtr_str_replace.php:60
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:291
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition
maintenance.txt:50
maintenance
benchmarks
bench_strtr_str_replace.php
Generated on Mon Nov 25 2024 15:35:56 for MediaWiki by
1.10.0