16 parent::__construct();
17 $this->
addOption(
'file',
'Path to file containing the input text',
false,
true );
21 $file = $this->
getOption(
'file', __DIR__ .
'/data/tidy/australia-untidy.html.gz' );
23 if ( $html ===
false ) {
24 $this->
fatalError(
"Unable to open input file" );
27 $this->benchmark( $html );
30 private function benchmark(
string $html ) {
32 $contLang = $services->getContentLanguage();
33 $tidy = $services->getTidy();
37 for ( $j = 1; $j <= $outerCount; $j++ ) {
38 $t = microtime(
true );
39 for ( $i = 0; $i < $innerCount; $i++ ) {
41 print $contLang->formatSize( memory_get_usage(
true ) ) .
"\n";
43 $t = ( ( microtime(
true ) -
$t ) / $innerCount ) * 1000;
49 sort( $times, SORT_NUMERIC );
55 $median = $times[ ( $n - 1 ) / 2 ];
57 $median = ( $times[$n / 2] + $times[$n / 2 - 1] ) / 2;
59 $mean = array_sum( $times ) / $n;
61 print
"Minimum: $min ms\n";
62 print
"Median: $median ms\n";
63 print
"Mean: $mean ms\n";
64 print
"Maximum: $max ms\n";
65 print
"Memory usage: " . $contLang->formatSize( memory_get_usage(
true ) ) .
"\n";
66 print
"Peak memory usage: " .
67 $contLang->formatSize( memory_get_peak_usage(
true ) ) .
"\n";
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.