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 = 'BenchWfBaseConvert'; require_once RUN_MAINTENANCE_IF_MAIN;