MediaWiki  REL1_31
benchmarkJSMinPlus.php
Go to the documentation of this file.
1 <?php
23 require_once __DIR__ . '/Benchmarker.php';
24 
31  protected $defaultCount = 10;
32 
33  public function __construct() {
34  parent::__construct();
35  $this->addDescription( 'Benchmarks JSMinPlus.' );
36  $this->addOption( 'file', 'Path to JS file', true, true );
37  }
38 
39  public function execute() {
40  Wikimedia\suppressWarnings();
41  $content = file_get_contents( $this->getOption( 'file' ) );
42  Wikimedia\restoreWarnings();
43  if ( $content === false ) {
44  $this->fatalError( 'Unable to open input file' );
45  }
46 
47  $filename = basename( $this->getOption( 'file' ) );
48  $parser = new JSParser();
49 
50  $this->bench( [
51  "JSParser::parse ($filename)" => [
52  'function' => function ( $parser, $content, $filename ) {
53  $parser->parse( $content, $filename, 1 );
54  },
55  'args' => [ $parser, $content, $filename ]
56  ]
57  ] );
58  }
59 }
60 
62 require_once RUN_MAINTENANCE_IF_MAIN;
BenchmarkJSMinPlus
Maintenance script that benchmarks JSMinPlus.
Definition: benchmarkJSMinPlus.php:30
BenchmarkJSMinPlus\$defaultCount
$defaultCount
Definition: benchmarkJSMinPlus.php:31
Maintenance\fatalError
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Definition: Maintenance.php:439
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:291
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:50
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2603
BenchmarkJSMinPlus\execute
execute()
Do the actual work.
Definition: benchmarkJSMinPlus.php:39
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition: Maintenance.php:219
$maintClass
$maintClass
Definition: benchmarkJSMinPlus.php:61
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:40
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:254
BenchmarkJSMinPlus\__construct
__construct()
Default constructor.
Definition: benchmarkJSMinPlus.php:33
JSParser
Definition: jsminplus.php:675
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:56