0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-18 11:41:52 +00:00

[1.1.1] Format millisecond timing, run the parser 3 times for a more fair comparison.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@450 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-09-24 18:45:24 +00:00
parent 4b5198c5bc
commit ad8310c1f5

View File

@ -9,6 +9,7 @@ require_once 'HTMLPurifier/ConfigSchema.php';
require_once 'HTMLPurifier/Config.php';
$LEXERS = array();
$RUNS = 3;
require_once 'HTMLPurifier/Lexer/DirectLex.php';
$LEXERS['DirectLex'] = new HTMLPurifier_Lexer_DirectLex();
@ -65,7 +66,7 @@ class RowTimer extends Benchmark_Timer
$perc = $v['diff'] * 100 / $standard;
$out .= '<td align="right">' . number_format($perc, 2, '.', '') .
'%</td><td>'.$v['diff'].'</td>';
'%</td><td>'.number_format($v['diff'],4,'.','').'</td>';
}
@ -86,13 +87,13 @@ function print_lexers() {
}
function do_benchmark($name, $document) {
global $LEXERS;
global $LEXERS, $RUNS;
$timer = new RowTimer($name);
$timer->start();
foreach($LEXERS as $key => $lexer) {
$tokens = $lexer->tokenizeHTML($document);
for ($i=0; $i<$RUNS; $i++) $tokens = $lexer->tokenizeHTML($document);
$timer->setMarker($key);
}