6require_once __DIR__ .
'/../includes/Benchmarker.php';
22 parent::__construct();
24 'Inner loop iterations',
false,
true );
29 'Code to run once before the first iteration',
31 $this->
addArg(
'input-file',
'Input file for measured code body',
false );
36 $setupCode = $this->
getOption(
'setup' ) .
';';
43 } elseif ( $this->
hasArg( 0 ) ) {
44 $code = file_get_contents( $this->
getArg( 0 ) );
45 if ( $code ===
false ) {
46 $this->
fatalError(
"Unable to read input file" );
49 fwrite( STDERR,
"Reading from stdin...\n" );
50 $code = stream_get_contents( STDIN );
55 $code =
"for ( \$__i = 0; \$__i < $inner; \$__i++ ) { $code }";
57 $code =
"function wfBenchmarkEvalBody () { $code }";
60 $this->
bench( [
'eval' => [
'function' =>
'wfBenchmarkEvalBody' ] ] );
66require_once RUN_MAINTENANCE_IF_MAIN;
Benchmark any provided code for ad-hoc benchmarks.
__construct()
Default constructor.
execute()
Do the actual work.
Base class for benchmark scripts.
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
hasArg( $argId=0)
Does a given argument exist?