From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- maintenance/benchmarks/Benchmarker.php | 2 +- maintenance/benchmarks/bench_strtr_str_replace.php | 4 +- maintenance/benchmarks/bench_wfBaseConvert.php | 77 ++++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 maintenance/benchmarks/bench_wfBaseConvert.php (limited to 'maintenance/benchmarks') diff --git a/maintenance/benchmarks/Benchmarker.php b/maintenance/benchmarks/Benchmarker.php index c198e0ff..98b35b53 100644 --- a/maintenance/benchmarks/Benchmarker.php +++ b/maintenance/benchmarks/Benchmarker.php @@ -75,7 +75,7 @@ abstract class Benchmarker extends Maintenance { } } - public function getFormattedResults( ) { + public function getFormattedResults() { $ret = ''; foreach( $this->results as $res ) { // show function with args diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php b/maintenance/benchmarks/bench_strtr_str_replace.php index 9fa7c8e3..10c5cd0b 100644 --- a/maintenance/benchmarks/bench_strtr_str_replace.php +++ b/maintenance/benchmarks/bench_strtr_str_replace.php @@ -26,11 +26,11 @@ require_once( __DIR__ . '/Benchmarker.php' ); function bfNormalizeTitleStrTr( $str ) { - return strtr( $str, '_', ' ' ); + return strtr( $str, '_', ' ' ); } function bfNormalizeTitleStrReplace( $str ) { - return str_replace( '_', ' ', $str ); + return str_replace( '_', ' ', $str ); } /** diff --git a/maintenance/benchmarks/bench_wfBaseConvert.php b/maintenance/benchmarks/bench_wfBaseConvert.php new file mode 100644 index 00000000..a1e5c6a4 --- /dev/null +++ b/maintenance/benchmarks/bench_wfBaseConvert.php @@ -0,0 +1,77 @@ +mDescription = "Benchmark for wfBaseConvert."; + $this->addOption( "inbase", "Input base", false, true ); + $this->addOption( "outbase", "Output base", false, true ); + $this->addOption( "length", "Size in digits to generate for input", false, true ); + } + + public function execute() { + $inbase = $this->getOption( "inbase", 36 ); + $outbase = $this->getOption( "outbase", 16 ); + $length = $this->getOption( "length", 128 ); + $number = self::makeRandomNumber( $inbase, $length ); + + $this->bench( array( + array( + 'function' => 'wfBaseConvert', + 'args' => array( $number, $inbase, $outbase, 0, true, 'php' ) + ), + array( + 'function' => 'wfBaseConvert', + 'args' => array( $number, $inbase, $outbase, 0, true, 'bcmath' ) + ), + array( + 'function' => 'wfBaseConvert', + 'args' => array( $number, $inbase, $outbase, 0, true, 'gmp' ) + ), + )); + + $this->output( $this->getFormattedResults() ); + } + + protected static function makeRandomNumber( $base, $length ) { + $baseChars = "0123456789abcdefghijklmnopqrstuvwxyz"; + $res = ""; + for( $i = 0; $i < $length; $i++ ) { + $res .= $baseChars[mt_rand(0, $base - 1)]; + } + return $res; + } +} + +$maintClass = 'bench_wfBaseConvert'; +require_once( RUN_MAINTENANCE_IF_MAIN ); -- cgit v1.2.3-54-g00ecf