MediaWiki REL1_30
benchmarkJSMinPlus.php
Go to the documentation of this file.
1<?php
23require_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 MediaWiki\suppressWarnings();
41 $content = file_get_contents( $this->getOption( 'file' ) );
42 MediaWiki\restoreWarnings();
43 if ( $content === false ) {
44 $this->error( 'Unable to open input file', 1 );
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
61$maintClass = 'BenchmarkJSMinPlus';
62require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that benchmarks JSMinPlus.
execute()
Do the actual work.
__construct()
Default constructor.
Base class for benchmark scripts.
bench(array $benchs)
addDescription( $text)
Set the description text.
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.
do that in ParserLimitReportFormat instead $parser
Definition hooks.txt:2572
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2581
require_once RUN_MAINTENANCE_IF_MAIN