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/bench_wfBaseConvert.php | 77 ++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 maintenance/benchmarks/bench_wfBaseConvert.php (limited to 'maintenance/benchmarks/bench_wfBaseConvert.php') 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.2