mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-01 11:50:28 +02: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:
@@ -9,6 +9,7 @@ require_once 'HTMLPurifier/ConfigSchema.php';
|
|||||||
require_once 'HTMLPurifier/Config.php';
|
require_once 'HTMLPurifier/Config.php';
|
||||||
|
|
||||||
$LEXERS = array();
|
$LEXERS = array();
|
||||||
|
$RUNS = 3;
|
||||||
|
|
||||||
require_once 'HTMLPurifier/Lexer/DirectLex.php';
|
require_once 'HTMLPurifier/Lexer/DirectLex.php';
|
||||||
$LEXERS['DirectLex'] = new HTMLPurifier_Lexer_DirectLex();
|
$LEXERS['DirectLex'] = new HTMLPurifier_Lexer_DirectLex();
|
||||||
@@ -65,7 +66,7 @@ class RowTimer extends Benchmark_Timer
|
|||||||
$perc = $v['diff'] * 100 / $standard;
|
$perc = $v['diff'] * 100 / $standard;
|
||||||
|
|
||||||
$out .= '<td align="right">' . number_format($perc, 2, '.', '') .
|
$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) {
|
function do_benchmark($name, $document) {
|
||||||
global $LEXERS;
|
global $LEXERS, $RUNS;
|
||||||
|
|
||||||
$timer = new RowTimer($name);
|
$timer = new RowTimer($name);
|
||||||
$timer->start();
|
$timer->start();
|
||||||
|
|
||||||
foreach($LEXERS as $key => $lexer) {
|
foreach($LEXERS as $key => $lexer) {
|
||||||
$tokens = $lexer->tokenizeHTML($document);
|
for ($i=0; $i<$RUNS; $i++) $tokens = $lexer->tokenizeHTML($document);
|
||||||
$timer->setMarker($key);
|
$timer->setMarker($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user