diff --git a/benchmarks/HTML_Lexer.php b/benchmarks/HTML_Lexer.php
index 19a8bac3..0ea39dc9 100644
--- a/benchmarks/HTML_Lexer.php
+++ b/benchmarks/HTML_Lexer.php
@@ -12,6 +12,43 @@ require_once 'Text/Password.php';
require_once '../MarkupFragment.php';
require_once '../HTML_Lexer.php';
+class TinyTimer extends Benchmark_Timer
+{
+
+ var $name;
+
+ function TinyTimer($name, $auto = false) {
+ $this->name = htmlentities($name);
+ $this->Benchmark_Timer($auto);
+ }
+
+ function getOutput() {
+
+ $total = $this->TimeElapsed();
+ $result = $this->getProfiling();
+ $dashes = '';
+
+ $out = '
';
+
+ $out .= "{$this->name} | ";
+
+ foreach ($result as $k => $v) {
+ if ($v['name'] == 'Start' || $v['name'] == 'Stop') continue;
+
+ $perc = (($v['diff'] * 100) / $total);
+ $tperc = (($v['total'] * 100) / $total);
+
+ $out .= '' . number_format($perc, 2, '.', '') .
+ "% | ";
+
+ }
+
+ $out .= '
';
+
+ return $out;
+ }
+}
+
?>
@@ -19,11 +56,13 @@ require_once '../HTML_Lexer.php';
Benchmark: HTML_Lexer versus HTMLSax
+
+Case | HTML_Lexer | HTML_Lexer_Sax |
start();
$lexer = new HTML_Lexer();
@@ -46,8 +85,7 @@ while (false !== ($filename = readdir($dh))) {
if (strpos($filename, '.html') !== strlen($filename) - 5) continue;
$document = file_get_contents($dir . '/' . $filename);
- echo "File: $filename
\n";
- do_benchmark($document);
+ do_benchmark("File: $filename", $document);
}
@@ -58,15 +96,24 @@ $snippets[] = '';
foreach ($snippets as $snippet) {
- echo '' . htmlentities($snippet) . '
';
- do_benchmark($snippet);
+ do_benchmark($snippet, $snippet);
}
// random input
-$document = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\'');
-echo "Random input
\n";
-echo '' . htmlentities($document) . '
';
-do_benchmark($document);
+$random = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\'');
-?>
\ No newline at end of file
+do_benchmark('Random input', $random);
+
+?>
+
+Random input was: ' .
+ '' . htmlentities($random) .
+ '';
+
+?>
+
+
+