MediaWiki  1.23.2
bench_wfBaseConvert.php
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/Benchmarker.php';
26 
33 
34  public function __construct() {
35  parent::__construct();
36  $this->mDescription = "Benchmark for wfBaseConvert.";
37  $this->addOption( "inbase", "Input base", false, true );
38  $this->addOption( "outbase", "Output base", false, true );
39  $this->addOption( "length", "Size in digits to generate for input", false, true );
40  }
41 
42  public function execute() {
43  $inbase = $this->getOption( "inbase", 36 );
44  $outbase = $this->getOption( "outbase", 16 );
45  $length = $this->getOption( "length", 128 );
46  $number = self::makeRandomNumber( $inbase, $length );
47 
48  $this->bench( array(
49  array(
50  'function' => 'wfBaseConvert',
51  'args' => array( $number, $inbase, $outbase, 0, true, 'php' )
52  ),
53  array(
54  'function' => 'wfBaseConvert',
55  'args' => array( $number, $inbase, $outbase, 0, true, 'bcmath' )
56  ),
57  array(
58  'function' => 'wfBaseConvert',
59  'args' => array( $number, $inbase, $outbase, 0, true, 'gmp' )
60  ),
61  ));
62 
63  $this->output( $this->getFormattedResults() );
64  }
65 
66  protected static function makeRandomNumber( $base, $length ) {
67  $baseChars = "0123456789abcdefghijklmnopqrstuvwxyz";
68  $res = "";
69  for( $i = 0; $i < $length; $i++ ) {
70  $res .= $baseChars[mt_rand(0, $base - 1)];
71  }
72  return $res;
73  }
74 }
75 
76 $maintClass = 'bench_wfBaseConvert';
77 require_once RUN_MAINTENANCE_IF_MAIN;
bench_wfBaseConvert\makeRandomNumber
static makeRandomNumber( $base, $length)
Definition: bench_wfBaseConvert.php:66
$maintClass
$maintClass
Definition: bench_wfBaseConvert.php:76
bench_wfBaseConvert\execute
execute()
Do the actual work.
Definition: bench_wfBaseConvert.php:42
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Benchmarker\getFormattedResults
getFormattedResults()
Definition: Benchmarker.php:78
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:45
bench_wfBaseConvert\__construct
__construct()
Default constructor.
Definition: bench_wfBaseConvert.php:34
bench_wfBaseConvert
Maintenance script that benchmarks wfBaseConvert().
Definition: bench_wfBaseConvert.php:32
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
$res
$res
Definition: database.txt:21