|
[FixedBug] Fatal error in benchmark tests February 12, 2007 11:43PM |
Registered: 6 years ago Posts: 3 |
hi,
sorry if my english is bad but I'm french :p
for my first post, congratulation for this package! many PHP dev search this and I am really happy that exists :D
I would like to try to do a benchmark, I browse the code in the benchmark directory but I have many error when I run lexer.php...
Warning: Missing argument 2 for HTMLPurifier_Lexer_DirectLex::tokenizeHTML(), called in .../htmlpurifier-1.4.1\benchmarks\Lexer.php on line 100 and defined in .../htmlpurifier-1.4.1\library\HTMLPurifier\Lexer\DirectLex.php on line 27
Warning: Missing argument 3 for HTMLPurifier_Lexer_DirectLex::tokenizeHTML(), called in .../htmlpurifier-1.4.1\benchmarks\Lexer.php on line 100 and defined in .../htmlpurifier-1.4.1\library\HTMLPurifier\Lexer\DirectLex.php on line 27
Notice: Undefined variable: config in .../htmlpurifier-1.4.1\library\HTMLPurifier\Lexer\DirectLex.php on line 29
Fatal error: Call to a member function get() on a non-object in .../htmlpurifier-1.4.1\library\HTMLPurifier\Lexer.php on line 203
I test to resolve that : I include $config = HTMLPurifier_Config::create($config); in the multiples functions called but after, more other errors are appeared ... ?
thanks!
Edited 1 time(s). Last edit at 04/02/2007 06:30AM by Ambush Commander.
|
Re: benchmark test ? February 13, 2007 03:34PM |
Admin Registered: 6 years ago Posts: 2,640 |
Oops, it looks like I haven't been keeping that code up to date. I'll fix it in the next release.
It's not a very interesting benchmark, really, it just compares the HTML parsing capabilities between DOM, PEAR's XML_HTMLSax3 and HTML Purifier's DirectLex. Last I checked, DOM was the fastest, followed by DirectLex and then HTMLSax3.
HTML Purifier, Standards Compliant HTML Filtering
|
Re: benchmark test ? February 13, 2007 03:52PM |
Admin Registered: 6 years ago Posts: 2,640 |
This patch should fix it:
Index: Lexer.php =================================================================== --- Lexer.php (revision 710) +++ Lexer.php (working copy) @@ -7,6 +7,7 @@ require_once 'HTMLPurifier/ConfigSchema.php'; require_once 'HTMLPurifier/Config.php'; +require_once 'HTMLPurifier/Context.php'; $LEXERS = array(); $RUNS = isset($GLOBALS['HTMLPurifierTest']['Runs']) @@ -93,11 +94,14 @@ 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); + for ($i=0; $i<$RUNS; $i++) $tokens = $lexer->tokenizeHTML($document, $config, $context); $timer->setMarker($key); } Index: ProfileDirectLex.php =================================================================== --- ProfileDirectLex.php (revision 710) +++ ProfileDirectLex.php (working copy) @@ -5,12 +5,15 @@ require_once 'HTMLPurifier/ConfigSchema.php'; require_once 'HTMLPurifier/Config.php'; require_once 'HTMLPurifier/Lexer/DirectLex.php'; +require_once 'HTMLPurifier/Context.php'; $input = file_get_contents('samples/Lexer/4.html'); $lexer = new HTMLPurifier_Lexer_DirectLex(); +$config = HTMLPurifier_Config::createDefault(); +$context = new HTMLPurifier_Context(); for ($i = 0; $i < 10; $i++) { - $tokens = $lexer->tokenizeHTML($input); + $tokens = $lexer->tokenizeHTML($input, $config, $context); } ?> \ No newline at end of file
HTML Purifier, Standards Compliant HTML Filtering
|
Re: benchmark test ? February 13, 2007 04:20PM |
Registered: 6 years ago Posts: 3 |