30 parent::__construct();
31 $this->
addOption(
'file',
'Path to file containing the input text',
false,
true );
35 $file = $this->
getOption(
'file', __DIR__ .
'/data/tidy/australia-untidy.html.gz' );
37 if ( $html ===
false ) {
38 $this->
fatalError(
"Unable to open input file" );
41 $this->benchmark( $html );
44 private function benchmark(
string $html ) {
46 $contLang = $services->getContentLanguage();
47 $tidy = $services->getTidy();
51 for ( $j = 1; $j <= $outerCount; $j++ ) {
52 $t = microtime(
true );
53 for ( $i = 0; $i < $innerCount; $i++ ) {
55 print $contLang->formatSize( memory_get_usage(
true ) ) .
"\n";
57 $t = ( ( microtime(
true ) -
$t ) / $innerCount ) * 1000;
63 sort( $times, SORT_NUMERIC );
69 $median = $times[ ( $n - 1 ) / 2 ];
71 $median = ( $times[$n / 2] + $times[$n / 2 - 1] ) / 2;
73 $mean = array_sum( $times ) / $n;
75 print
"Minimum: $min ms\n";
76 print
"Median: $median ms\n";
77 print
"Mean: $mean ms\n";
78 print
"Maximum: $max ms\n";
79 print
"Memory usage: " . $contLang->formatSize( memory_get_usage(
true ) ) .
"\n";
80 print
"Peak memory usage: " .
81 $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.