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); echo "

File: $filename

\n"; do_benchmark($document); } // crashers $snippets = array(); $snippets[] = ''; foreach ($snippets as $snippet) { echo '

' . htmlentities($snippet) . '

'; do_benchmark($snippet); } // random input $document = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\''); echo "

Random input

\n"; echo '

' . htmlentities($document) . '

'; do_benchmark($document); ?>