MediaWiki REL1_32
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 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
61$maintClass = BenchmarkJSMinPlus::class;
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1873
require_once RUN_MAINTENANCE_IF_MAIN
$content