Use WikiPage instead of Article to call updateCategoryCounts()
[lhc/web/wiklou.git] / maintenance / benchmarks / bench_strtr_str_replace.php
1 <?php
2
3 require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
4
5 function bfNormalizeTitleStrTr( $str ) {
6 return strtr( $str, '_', ' ' );
7 }
8
9 function bfNormalizeTitleStrReplace( $str ) {
10 return str_replace( '_', ' ', $str );
11 }
12
13 class bench_strtr_str_replace extends Benchmarker {
14
15 public function __construct() {
16 parent::__construct();
17 $this->mDescription = "Benchmark for strtr() vs str_replace().";
18 }
19
20 public function execute() {
21 $this->bench( array(
22 array( 'function' => array( $this, 'benchstrtr' ) ),
23 array( 'function' => array( $this, 'benchstr_replace' ) ),
24 array( 'function' => array( $this, 'benchstrtr_indirect' ) ),
25 array( 'function' => array( $this, 'benchstr_replace_indirect' ) ),
26 ));
27 print $this->getFormattedResults();
28 }
29
30 function benchstrtr() {
31 strtr( "[[MediaWiki:Some_random_test_page]]", "_", " " );
32 }
33
34 function benchstr_replace() {
35 str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]");
36 }
37
38
39 function benchstrtr_indirect() {
40 bfNormalizeTitleStrTr( "[[MediaWiki:Some_random_test_page]]" );
41 }
42
43 function benchstr_replace_indirect() {
44 bfNormalizeTitleStrReplace( "[[MediaWiki:Some_random_test_page]]" );
45 }
46
47 }
48
49 $maintClass = 'bench_strtr_str_replace';
50 require_once( RUN_MAINTENANCE_IF_MAIN );