Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6015759
benchmarkTidy.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
benchmarkTidy.php
View Options
<?php
/**
* @license GPL-2.0-or-later
* @file
* @ingroup Benchmark
*/
use
MediaWiki\Maintenance\Benchmarker
;
// @codeCoverageIgnoreStart
require_once
__DIR__
.
'/../includes/Benchmarker.php'
;
// @codeCoverageIgnoreEnd
class
BenchmarkTidy
extends
Benchmarker
{
public
function
__construct
()
{
parent
::
__construct
();
$this
->
addOption
(
'file'
,
'Path to file containing the input text'
,
false
,
true
);
}
public
function
execute
()
{
$file
=
$this
->
getOption
(
'file'
,
__DIR__
.
'/data/tidy/australia-untidy.html.gz'
);
$html
=
$this
->
loadFile
(
$file
);
if
(
$html
===
false
)
{
$this
->
fatalError
(
"Unable to open input file"
);
}
$this
->
benchmark
(
$html
);
}
private
function
benchmark
(
string
$html
)
{
$services
=
$this
->
getServiceContainer
();
$contLang
=
$services
->
getContentLanguage
();
$tidy
=
$services
->
getTidy
();
$times
=
[];
$innerCount
=
10
;
$outerCount
=
10
;
for
(
$j
=
1
;
$j
<=
$outerCount
;
$j
++
)
{
$t
=
microtime
(
true
);
for
(
$i
=
0
;
$i
<
$innerCount
;
$i
++
)
{
$tidy
->
tidy
(
$html
);
print
$contLang
->
formatSize
(
memory_get_usage
(
true
)
)
.
"
\n
"
;
}
$t
=
(
(
microtime
(
true
)
-
$t
)
/
$innerCount
)
*
1000
;
$times
[]
=
$t
;
print
"Run $j: $t
\n
"
;
}
print
"
\n
"
;
sort
(
$times
,
SORT_NUMERIC
);
$n
=
$outerCount
;
$min
=
$times
[
0
];
$max
=
end
(
$times
);
if
(
$n
%
2
)
{
// @phan-suppress-next-line PhanTypeMismatchDimFetch
$median
=
$times
[
(
$n
-
1
)
/
2
];
}
else
{
$median
=
(
$times
[
$n
/
2
]
+
$times
[
$n
/
2
-
1
]
)
/
2
;
}
$mean
=
array_sum
(
$times
)
/
$n
;
print
"Minimum: $min ms
\n
"
;
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
"Peak memory usage: "
.
$contLang
->
formatSize
(
memory_get_peak_usage
(
true
)
)
.
"
\n
"
;
}
}
// @codeCoverageIgnoreStart
$maintClass
=
BenchmarkTidy
::
class
;
require_once
RUN_MAINTENANCE_IF_MAIN
;
// @codeCoverageIgnoreEnd
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 4 2026, 11:16 (5 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c6/8d/57370114fdf52cfac2ead12fee7a
Default Alt Text
benchmarkTidy.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment