MediaWiki REL1_32
benchmarkJavaScriptMinifier.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( 'Benchmark for JavaScriptMinifier.' );
36 $this->addOption( 'file', 'Path to JavaScript file (may be gzipped)', false, true );
37 }
38
39 public function execute() {
40 $file = $this->getOption( 'file', __DIR__ . '/jsmin/jquery-3.2.1.js.gz' );
41 $filename = basename( $file );
42 $content = $this->loadFile( $file );
43 if ( $content === false ) {
44 $this->fatalError( 'Unable to open input file' );
45 }
46
47 $this->bench( [
48 "minify ($filename)" => [
49 'function' => [ JavaScriptMinifier::class, 'minify' ],
50 'args' => [ $content ],
51 ],
52 ] );
53 }
54}
55
56$maintClass = BenchmarkJavaScriptMinifier::class;
57require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that benchmarks JavaScriptMinifier.
Base class for benchmark scripts.
bench(array $benchs)
loadFile( $file)
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.
require_once RUN_MAINTENANCE_IF_MAIN
$content