MediaWiki  master
benchmarkCSSMin.php
Go to the documentation of this file.
1 <?php
23 require_once __DIR__ . '/Benchmarker.php';
24 
31  public function __construct() {
32  parent::__construct();
33  $this->addDescription( 'Benchmarks CSSMin.' );
34  $this->addOption( 'file', 'Path to CSS file (may be gzipped)', false, true );
35  $this->addOption( 'out', 'Echo output of one run to stdout for inspection', false, false );
36  }
37 
38  public function execute() {
39  $file = $this->getOption( 'file', __DIR__ . '/cssmin/styles.css' );
40  $filename = basename( $file );
41  $css = $this->loadFile( $file );
42 
43  if ( $this->hasOption( 'out' ) ) {
44  echo "## minify\n\n",
46  "\n\n";
47  echo "## remap\n\n",
48  CSSMin::remap( $css, dirname( $file ), 'https://example.org/test/', true ),
49  "\n";
50  return;
51  }
52 
53  $this->bench( [
54  "minify ($filename)" => [
55  'function' => [ CSSMin::class, 'minify' ],
56  'args' => [ $css ]
57  ],
58  "remap ($filename)" => [
59  'function' => [ CSSMin::class, 'remap' ],
60  'args' => [ $css, dirname( $file ), 'https://example.org/test/', true ]
61  ],
62  ] );
63  }
64 }
65 
67 require_once RUN_MAINTENANCE_IF_MAIN;
getOption( $name, $default=null)
Get an option, or return the default.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Definition: router.php:42
static minify( $css)
Removes whitespace from CSS data.
Definition: CSSMin.php:540
hasOption( $name)
Checks to see if a particular option exists.
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
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:239
$maintClass
bench(array $benchs)
Definition: Benchmarker.php:50
$css
addDescription( $text)
Set the description text.
loadFile( $file)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Maintenance script that benchmarks CSSMin.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.