From ad8310c1f56b8bb99ce252727695bde03402c481 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 24 Sep 2006 18:45:24 +0000 Subject: [PATCH] [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 --- benchmarks/Lexer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/benchmarks/Lexer.php b/benchmarks/Lexer.php index d7da3841..7769dae0 100644 --- a/benchmarks/Lexer.php +++ b/benchmarks/Lexer.php @@ -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 .= '' . number_format($perc, 2, '.', '') . - '%'.$v['diff'].''; + '%'.number_format($v['diff'],4,'.','').''; } @@ -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); }