9a2888638793912972ec9546998944b25e7a2b59
[lhc/web/wiklou.git] / maintenance / benchmarks / bench_strtr_str_replace.php
1 <?php
2
3 require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
4 class bench_strtr_str_replace extends Benchmarker {
5
6 public function __construct() {
7 parent::__construct();
8 $this->mDescription = "Benchmark for strtr() vs str_replace().";
9 }
10
11 public function execute() {
12 $this->bench( array(
13 array( 'function' => array( $this, 'benchstrtr' ) ),
14 array( 'function' => array( $this, 'benchstr_replace' ) ),
15 ));
16 print $this->getFormattedResults();
17 }
18
19 function benchstrtr() {
20 strtr( "[[MediaWiki:Some_random_test_page]]", "_", "" );
21 }
22
23 function benchstr_replace() {
24 str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]");
25 }
26
27 }
28
29 $maintClass = 'bench_strtr_str_replace';
30 require_once( DO_MAINTENANCE );