Simple benchmark test for PHP HTML Parser.
Download from the release page or clone the repo
git clone https://github.com/ewwink/php-html-parser-benchmarks
cd php-html-parser-benchmarks
Install required dependency using composer
composer install
Run the benchmark
php bench.php
- DOMDocument
- DiDOM
- DomCrawler
- hQuery
- HTML5DOMDocument
- nokogiri
- Simple HTML DOM
- zend-dom
- PHP Html Parser
- OS: Windows 7 64bit
- PHP 7.1.4 (cli) ( ZTS MSVC14 (Visual C++ 2015) x86 )
- Python 3.7.0
note: *
element modification not supported
+------------------------+------------+-------------+
| Parser | Time (sec) | Memory (kB) |
+------------------------+------------+-------------+
| hQuery* | 0.047 | 499 |
| HTML5DOMDocument | 0.047 | 2339 |
| DOMDocument | 0.062 | 0.664 |
| nokogiri* | 0.062 | 5350 |
| SimpleHTMLDOM | 0.062 | 402 |
| DiDOM | 0.078 | 297 |
| phphtmlparser | 0.094 | 357 |
| zend-dom* | 0.094 | 70 |
| DomCrawler | 0.109 | 505 |
+------------------------+------------+-------------+
| BeautifulSoup (Python | 0.078 | - |
+------------------------+------------+-------------+
+------------------------+------------+-------------+
| Parser | Time (sec) | Memory (kB) |
+------------------------+------------+-------------+
| DOMDocument | 0.016 | 0 |
| hQuery* | 0.047 | 0 |
| SimpleHTMLDOM | 0.140 | 75 |
| HTML5DOMDocument | 0.234 | 2557 |
| DiDOM | 0.234 | 0 |
| nokogiri* | 0.296 | - |
| DomCrawler | 0.468 | 0 |
| zend-dom* | 0.640 | 0 |
| phphtmlparser | 0.720 | 74 |
+------------------------+------------+-------------+
| BeautifulSoup (Python | 0.876 | - |
+------------------------+------------+-------------+
+------------------------+------------+-------------+
| Parser | Time (sec) | Memory (kB) |
+------------------------+------------+-------------+
| DOMDocument | 0.187 | 0 |
| hQuery* | 0.485 | 0 |
| SimpleHTMLDOM | 1.405 | 75 |
| DiDOM | 2.325 | 0 |
| HTML5DOMDocument | 2.419 | 84 |
| nokogiri* | 2.871 | 0 |
| DomCrawler | 4.557 | 0 |
| zend-dom* | 6.242 | 0 |
| phphtmlparser | 7.210 | 74 |
+------------------------+------------+-------------+
| BeautifulSoup (Python | 8.755 | - |
+------------------------+------------+-------------+
+------------------------+-------------+-------------+
| Parser | Time (sec) | Memory (kB) |
+------------------------+-------------+-------------+
| DOMDocument | 0.016 | 0.047 |
| DiDOM | 0.031 | 0.063 |
| DomCrawler | 0.047 | 0.766 |
| HTML5DOMDocument | 0.047 | - |
| SimpleHTMLDOM | 0.109 | 408 |
| phphtmlparser | 0.374 | - |
| hQuery | not support | not support |
| nokogiri | not support | not support |
| zend-dom | not support | not support |
+------------------------+-------------+-------------+
| BeautifulSoup (Python | 0.234 | - |
+------------------------+-------------+-------------+
+------------------------+-------------+-------------+
| Parser | Time (sec) | Memory (kB) |
+------------------------+-------------+-------------+
| DOMDocument | 0.109 | 0 |
| HTML5DOMDocument | 0.421 | 2952 |
| DiDOM | 0.422 | 0 |
| DomCrawler | 0.484 | 0 |
| SimpleHTMLDOM | 1.342 | 3948 |
| phphtmlparser | 3.651 | - |
| hQuery | not support | not support |
| nokogiri | not support | not support |
| zend-dom | not support | not support |
+------------------------+-------------+-------------+
| BeautifulSoup (Python | 2.231 | - |
+------------------------+-------------+-------------+
+------------------------+-------------+-------------+
| Parser | Time (sec) | Memory (kB) |
+------------------------+-------------+-------------+
| DOMDocument | 1.092 | 0 |
| DiDOM | 4.151 | 0 |
| HTML5DOMDocument | 4.292 | 747 |
| DomCrawler | 4.822 | 0 |
| SimpleHTMLDOM | 13.859 | - |
| phphtmlparser | 36.394 | 1178 |
| hQuery | not support | not support |
| nokogiri | not support | not support |
| zend-dom | not support | not support |
+------------------------+-------------+-------------+
| BeautifulSoup (Python | 22.506 | - |
+------------------------+-------------+-------------+