11require_once __DIR__ .
'/../includes/Benchmarker.php';
22 parent::__construct();
26 'A json file, or a php file that returns a data structure. Default is config-schema.php',
32 'Whether JSON objects should be represented as associative arrays when loading'
37 $file = $this->
getOption(
'file', MW_INSTALL_PATH .
'/includes/config-schema.php' );
38 $data = $this->loadData( $file );
39 $bytes = json_encode( $data );
44 "JsonCodec::serialize ($file)" => [
45 'function' =>
static function (
JsonCodec $codec, $data ) {
48 'args' => [ $codec, $data ]
50 "JsonCodec::deserialize ($file)" => [
51 'function' =>
static function (
JsonCodec $codec, $bytes ) {
54 'args' => [ $codec, $bytes ]
56 "JsonCodec::detectNonSerializableData ($file)" => [
57 'function' =>
static function (
JsonCodec $codec, $data ) {
60 'args' => [ $codec, $data ]
66 private function loadData(
string $file ) {
67 if ( str_ends_with( $file,
'.php' ) ) {
68 $data = include $file;
70 $this->
fatalError(
"Failed to load data from " . $file );
76 $data = json_decode( $raw, $this->
getOption(
'assoc',
false ) );
79 $this->
fatalError(
"Failed to load data from " . $file );
88require_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.