new HTMLPurifier_Lexer_DirectLex(), 'PEARSax3' => new HTMLPurifier_Lexer_PEARSax3() ); if (version_compare(PHP_VERSION, '5', '>=')) { require_once 'HTMLPurifier/Lexer/DOMLex.php'; $LEXERS['DOMLex'] = new HTMLPurifier_Lexer_DOMLex(); } // PEAR require_once 'Benchmark/Timer.php'; // to do the timing require_once 'Text/Password.php'; // for generating random input // custom class to aid unit testing class RowTimer extends Benchmark_Timer { var $name; function RowTimer($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 .= '' . $v['diff'] . ''; //$out .= '' . number_format($perc, 2, '.', '') . // '%'; } $out .= ''; return $out; } } function print_lexers() { global $LEXERS; $first = true; foreach ($LEXERS as $key => $value) { if (!$first) echo ' / '; echo htmlspecialchars($key); $first = false; } } function do_benchmark($name, $document) { global $LEXERS; $timer = new RowTimer($name); $timer->start(); foreach($LEXERS as $key => $lexer) { $tokens = $lexer->tokenizeHTML($document); $timer->setMarker($key); } $timer->stop(); $timer->display(); } ?> Benchmark: <?php print_lexers(); ?>

Benchmark:

$value) { echo ''; } ?>'; $snippets[] = ''; foreach ($snippets as $snippet) { do_benchmark($snippet, $snippet); } // random input $random = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\''); do_benchmark('Random input', $random); ?>
Case' . htmlspecialchars($key) . '
Random input was: ' . '' . htmlspecialchars($random) . ''; ?>