25require_once __DIR__ .
'/../includes/Benchmarker.php';
36 parent::__construct();
40 'A json file, or a php file that returns a data structure. Default is config-schema.php',
46 'Whether JSON objects should be represented as associative arrays when loading'
51 $file = $this->
getOption(
'file', MW_INSTALL_PATH .
'/includes/config-schema.php' );
52 $data = $this->loadData( $file );
53 $bytes = json_encode( $data );
58 "JsonCodec::serialize ($file)" => [
59 'function' =>
static function (
JsonCodec $codec, $data ) {
62 'args' => [ $codec, $data ]
64 "JsonCodec::deserialize ($file)" => [
65 'function' =>
static function (
JsonCodec $codec, $bytes ) {
68 'args' => [ $codec, $bytes ]
70 "JsonCodec::detectNonSerializableData ($file)" => [
71 'function' =>
static function (
JsonCodec $codec, $data ) {
74 'args' => [ $codec, $data ]
80 private function loadData(
string $file ) {
81 if ( str_ends_with( $file,
'.php' ) ) {
82 $data = include $file;
84 $this->
fatalError(
"Failed to load data from " . $file );
90 $data = json_decode( $raw, $this->
getOption(
'assoc',
false ) );
93 $this->
fatalError(
"Failed to load data from " . $file );
102require_once RUN_MAINTENANCE_IF_MAIN;
execute()
Do the actual work.
__construct()
Default constructor.
Base class for benchmark scripts.
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.
getOption( $name, $default=null)
Get an option, or return the default.
addDescription( $text)
Set the description text.