8require_once __DIR__ .
'/../includes/Benchmarker.php';
13 parent::__construct();
15 $this->
addOption(
'file',
'A JSON API result from list=recentchanges',
21 __DIR__ .
'/data/CommentFormatter/rc100-2021-07-29.json' );
22 $json = file_get_contents( $file );
24 $this->
fatalError(
"Unable to read input file \"$file\"" );
26 $result = json_decode( $json,
true );
27 if ( !isset( $result[
'query'][
'recentchanges'] ) ) {
30 $entries = $result[
'query'][
'recentchanges'];
33 foreach ( $entries as $entry ) {
35 'comment' => $entry[
'comment'],
36 'title' => Title::newFromText( $entry[
'title'] )
38 $comments[] = $entry[
'comment'];
41 'CommentFormatter::format' => [
42 'function' =>
function () use ( $inputs ) {
45 foreach ( $inputs as $input ) {
54 'CommentFormatter::createBatch' => [
55 'function' =>
function () use ( $inputs ) {
59 foreach ( $inputs as $input ) {
60 $comments[] = (
new CommentItem( $input[
'comment'] ) )
61 ->selfLinkTarget( $input[
'title'] );
63 $formatter->createBatch()
64 ->comments( $comments )
69 'CommentFormatter::formatStrings' => [
70 'function' =>
function () use ( $comments ) {
73 $formatter->formatStrings( $comments );
83require_once RUN_MAINTENANCE_IF_MAIN;
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.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.