Merge "Simplify HTMLTitleTextField::validate"
[lhc/web/wiklou.git] / maintenance / benchmarks / benchmarkTidy.php
index 5a432fb..558fec8 100644 (file)
@@ -2,12 +2,12 @@
 
 use MediaWiki\MediaWikiServices;
 
-require __DIR__ . '/../Maintenance.php';
+require __DIR__ . '/Benchmarker.php';
 
-class BenchmarkTidy extends Maintenance {
+class BenchmarkTidy extends Benchmarker {
        public function __construct() {
                parent::__construct();
-               $this->addOption( 'file', 'A filename which contains the input text', true, true );
+               $this->addOption( 'file', 'Path to file containing the input text', false, true );
                $this->addOption( 'driver', 'The Tidy driver name, or false to use the configured instance',
                        false,  true );
                $this->addOption( 'tidy-config', 'JSON encoded value for the tidy configuration array',
@@ -15,7 +15,8 @@ class BenchmarkTidy extends Maintenance {
        }
 
        public function execute() {
-               $html = file_get_contents( $this->getOption( 'file' ) );
+               $file = $this->getOption( 'file', __DIR__ . '/tidy/australia-untidy.html.gz' );
+               $html = $this->loadFile( $file );
                if ( $html === false ) {
                        $this->fatalError( "Unable to open input file" );
                }
@@ -68,7 +69,7 @@ class BenchmarkTidy extends Maintenance {
                print "Median: $median ms\n";
                print "Mean: $mean ms\n";
                print "Maximum: $max ms\n";
-               print "Memory usage: " .  $contLang->formatSize( memory_get_usage( true ) ) . "\n";
+               print "Memory usage: " . $contLang->formatSize( memory_get_usage( true ) ) . "\n";
                print "Peak memory usage: " .
                        $contLang->formatSize( memory_get_peak_usage( true ) ) . "\n";
        }