From: Sam Reed Date: Thu, 6 Jan 2011 21:00:44 +0000 (+0000) Subject: Add benchmark for bug 26605 Use strtr instead of str_replace when possible X-Git-Tag: 1.31.0-rc.0~32744 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=d8daa0c5e0dc15023f12ee3d8fef3b6477f999f1;p=lhc%2Fweb%2Fwiklou.git Add benchmark for bug 26605 Use strtr instead of str_replace when possible --- diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php b/maintenance/benchmarks/bench_strtr_str_replace.php new file mode 100644 index 0000000000..9a28886387 --- /dev/null +++ b/maintenance/benchmarks/bench_strtr_str_replace.php @@ -0,0 +1,30 @@ +mDescription = "Benchmark for strtr() vs str_replace()."; + } + + public function execute() { + $this->bench( array( + array( 'function' => array( $this, 'benchstrtr' ) ), + array( 'function' => array( $this, 'benchstr_replace' ) ), + )); + print $this->getFormattedResults(); + } + + function benchstrtr() { + strtr( "[[MediaWiki:Some_random_test_page]]", "_", "" ); + } + + function benchstr_replace() { + str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]"); + } + +} + +$maintClass = 'bench_strtr_str_replace'; +require_once( DO_MAINTENANCE );