=')) { require_once 'HTMLPurifier/Lexer/DOMLex.php'; $LEXERS['DOMLex'] = new HTMLPurifier_Lexer_DOMLex(); } // 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}"; $standard = false; 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'] . ''; if ($standard == false) $standard = $v['diff']; $perc = $v['diff'] * 100 / $standard; $bad_run = ($v['diff'] < 0); $out .= '' . number_format($perc, 2, '.', '') . '%'.number_format($v['diff'],4,'.','').''; } $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, $RUNS; $config = HTMLPurifier_Config::createDefault(); $context = new HTMLPurifier_Context(); $timer = new RowTimer($name); $timer->start(); foreach($LEXERS as $key => $lexer) { for ($i=0; $i<$RUNS; $i++) $tokens = $lexer->tokenizeHTML($document, $config, $context); $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) . ''; ?>