Index: trunk/phase3/maintenance/benchmarks/bench_strtr_str_replace.php |
— | — | @@ -0,0 +1,30 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once( dirname( __FILE__ ) . '/Benchmarker.php' ); |
| 5 | +class bench_strtr_str_replace extends Benchmarker { |
| 6 | + |
| 7 | + public function __construct() { |
| 8 | + parent::__construct(); |
| 9 | + $this->mDescription = "Benchmark for strtr() vs str_replace()."; |
| 10 | + } |
| 11 | + |
| 12 | + public function execute() { |
| 13 | + $this->bench( array( |
| 14 | + array( 'function' => array( $this, 'benchstrtr' ) ), |
| 15 | + array( 'function' => array( $this, 'benchstr_replace' ) ), |
| 16 | + )); |
| 17 | + print $this->getFormattedResults(); |
| 18 | + } |
| 19 | + |
| 20 | + function benchstrtr() { |
| 21 | + strtr( "[[MediaWiki:Some_random_test_page]]", "_", "" ); |
| 22 | + } |
| 23 | + |
| 24 | + function benchstr_replace() { |
| 25 | + str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]"); |
| 26 | + } |
| 27 | + |
| 28 | +} |
| 29 | + |
| 30 | +$maintClass = 'bench_strtr_str_replace'; |
| 31 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/phase3/maintenance/benchmarks/bench_strtr_str_replace.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 32 | + native |