X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2Fbenchmarks%2FbenchmarkTidy.php;h=558fec8cebefdd2fdd2149b1ca0325eb6936fbdf;hp=f2939b33df0357f603bc044e0b3bcb8121b7057f;hb=74d04edec385aa86ee01943b9a27475d79f74e78;hpb=faf7cc4a09848c538320bd2b9067b1a77c0a0183 diff --git a/maintenance/benchmarks/benchmarkTidy.php b/maintenance/benchmarks/benchmarkTidy.php index f2939b33df..558fec8ceb 100644 --- a/maintenance/benchmarks/benchmarkTidy.php +++ b/maintenance/benchmarks/benchmarkTidy.php @@ -1,11 +1,13 @@ 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', @@ -13,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" ); } @@ -35,8 +38,7 @@ class BenchmarkTidy extends Maintenance { } private function benchmark( $driver, $html ) { - global $wgContLang; - + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); $times = []; $innerCount = 10; $outerCount = 10; @@ -44,7 +46,7 @@ class BenchmarkTidy extends Maintenance { $t = microtime( true ); for ( $i = 0; $i < $innerCount; $i++ ) { $driver->tidy( $html ); - print $wgContLang->formatSize( memory_get_usage( true ) ) . "\n"; + print $contLang->formatSize( memory_get_usage( true ) ) . "\n"; } $t = ( ( microtime( true ) - $t ) / $innerCount ) * 1000; $times[] = $t; @@ -67,10 +69,9 @@ class BenchmarkTidy extends Maintenance { print "Median: $median ms\n"; print "Mean: $mean ms\n"; print "Maximum: $max ms\n"; - print "Memory usage: " . - $wgContLang->formatSize( memory_get_usage( true ) ) . "\n"; + print "Memory usage: " . $contLang->formatSize( memory_get_usage( true ) ) . "\n"; print "Peak memory usage: " . - $wgContLang->formatSize( memory_get_peak_usage( true ) ) . "\n"; + $contLang->formatSize( memory_get_peak_usage( true ) ) . "\n"; } }