MediaWiki  1.34.0
benchmarkCSSMin.php
Go to the documentation of this file.
1 <?php
22 require_once __DIR__ . '/Benchmarker.php';
23 
30  public function __construct() {
31  parent::__construct();
32  $this->addDescription( 'Benchmarks CSSMin.' );
33  $this->addOption( 'file', 'Path to CSS file (may be gzipped)', false, true );
34  $this->addOption( 'out', 'Echo output of one run to stdout for inspection', false, false );
35  }
36 
37  public function execute() {
38  $file = $this->getOption( 'file', __DIR__ . '/cssmin/styles.css' );
39  $filename = basename( $file );
40  $css = $this->loadFile( $file );
41 
42  if ( $this->hasOption( 'out' ) ) {
43  echo "## minify\n\n",
44  CSSMin::minify( $css ),
45  "\n\n";
46  echo "## remap\n\n",
47  CSSMin::remap( $css, dirname( $file ), 'https://example.org/test/', true ),
48  "\n";
49  return;
50  }
51 
52  $this->bench( [
53  "minify ($filename)" => [
54  'function' => [ CSSMin::class, 'minify' ],
55  'args' => [ $css ]
56  ],
57  "remap ($filename)" => [
58  'function' => [ CSSMin::class, 'remap' ],
59  'args' => [ $css, dirname( $file ), 'https://example.org/test/', true ]
60  ],
61  ] );
62  }
63 }
64 
65 $maintClass = BenchmarkCSSMin::class;
66 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
BenchmarkCSSMin\__construct
__construct()
Default constructor.
Definition: benchmarkCSSMin.php:30
BenchmarkCSSMin\execute
execute()
Do the actual work.
Definition: benchmarkCSSMin.php:37
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:50
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition: Maintenance.php:267
$maintClass
$maintClass
Definition: benchmarkCSSMin.php:65
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:40
BenchmarkCSSMin
Maintenance script that benchmarks CSSMin.
Definition: benchmarkCSSMin.php:29
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:302
Benchmarker\loadFile
loadFile( $file)
Definition: Benchmarker.php:182
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular option exists.
Definition: Maintenance.php:288