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; } } ?> Benchmark: HTML_Lexer versus HTMLSax

Benchmark: HTML_Lexer versus HTMLSax

start(); $lexer = new HTML_Lexer(); $tokens = $lexer->tokenizeHTML($document); $timer->setMarker('HTML_Lexer'); $lexer = new HTML_Lexer_Sax(); $sax_tokens = $lexer->tokenizeHTML($document); $timer->setMarker('HTML_Lexer_Sax'); $timer->stop(); $timer->display(); } // sample of html pages $dir = 'samples/HTML_Lexer'; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { if (strpos($filename, '.html') !== strlen($filename) - 5) continue; $document = file_get_contents($dir . '/' . $filename); do_benchmark("File: $filename", $document); } // crashers $snippets = array(); $snippets[] = ''; foreach ($snippets as $snippet) { do_benchmark($snippet, $snippet); } // random input $random = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\''); do_benchmark('Random input', $random); ?>
CaseHTML_LexerHTML_Lexer_Sax
Random input was: ' . '' . htmlentities($random) . ''; ?>