MediaWiki REL1_35
benchmarkCSSMin.php
Go to the documentation of this file.
1<?php
22require_once __DIR__ . '/../includes/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;
66require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
$maintClass
Maintenance script that benchmarks CSSMin.
execute()
Do the actual work.
__construct()
Default constructor.
Base class for benchmark scripts.
bench(array $benchs)
loadFile( $file)
static minify( $css)
Removes whitespace from CSS data.
Definition CSSMin.php:476
static remap( $source, $local, $remote, $embedData=true)
Remaps CSS URL paths and automatically embeds data URIs for CSS rules or url() values preceded by an ...
Definition CSSMin.php:238
hasOption( $name)
Checks to see if a particular option was set.
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.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition router.php:42