From d8daa0c5e0dc15023f12ee3d8fef3b6477f999f1 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 6 Jan 2011 21:00:44 +0000 Subject: [PATCH] Add benchmark for bug 26605 Use strtr instead of str_replace when possible --- .../benchmarks/bench_strtr_str_replace.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 maintenance/benchmarks/bench_strtr_str_replace.php 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 ); -- 2.20.1