MediaWiki  1.23.14
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 
42 
43  public function __construct() {
44  parent::__construct();
45  $this->mDescription = "Benchmark for strtr() vs str_replace().";
46  }
47 
48  public function execute() {
49  $this->bench( array(
50  array( 'function' => array( $this, 'benchstrtr' ) ),
51  array( 'function' => array( $this, 'benchstr_replace' ) ),
52  array( 'function' => array( $this, 'benchstrtr_indirect' ) ),
53  array( 'function' => array( $this, 'benchstr_replace_indirect' ) ),
54  ));
55  print $this->getFormattedResults();
56  }
57 
58  function benchstrtr() {
59  strtr( "[[MediaWiki:Some_random_test_page]]", "_", " " );
60  }
61 
62  function benchstr_replace() {
63  str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]");
64  }
65 
66  function benchstrtr_indirect() {
67  bfNormalizeTitleStrTr( "[[MediaWiki:Some_random_test_page]]" );
68  }
69 
71  bfNormalizeTitleStrReplace( "[[MediaWiki:Some_random_test_page]]" );
72  }
73 
74 }
75 
76 $maintClass = 'bench_strtr_str_replace';
77 require_once RUN_MAINTENANCE_IF_MAIN;
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
bfNormalizeTitleStrTr
bfNormalizeTitleStrTr( $str)
Definition: bench_strtr_str_replace.php:28
Benchmarker\getFormattedResults
getFormattedResults()
Definition: Benchmarker.php:78
bench_strtr_str_replace\__construct
__construct()
Default constructor.
Definition: bench_strtr_str_replace.php:43
bench_strtr_str_replace\benchstrtr
benchstrtr()
Definition: bench_strtr_str_replace.php:58
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$maintClass
$maintClass
Definition: bench_strtr_str_replace.php:76
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:45
bench_strtr_str_replace\benchstr_replace
benchstr_replace()
Definition: bench_strtr_str_replace.php:62
bench_strtr_str_replace
Maintenance script that benchmarks for strtr() vs str_replace().
Definition: bench_strtr_str_replace.php:41
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
bench_strtr_str_replace\benchstrtr_indirect
benchstrtr_indirect()
Definition: bench_strtr_str_replace.php:66
bfNormalizeTitleStrReplace
bfNormalizeTitleStrReplace( $str)
Definition: bench_strtr_str_replace.php:32
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
bench_strtr_str_replace\benchstr_replace_indirect
benchstr_replace_indirect()
Definition: bench_strtr_str_replace.php:70
bench_strtr_str_replace\execute
execute()
Do the actual work.
Definition: bench_strtr_str_replace.php:48