Benchmark of Markdown Parsers written in PHP - 12 Nov 2013

I made a benchmark of my markdown parser (kzykhys/ciconia). And also compared it to other php libraries.

Benchmark script is available on github

Results

$ php bin/markbench benchmark --profile=blank
Runtime: PHP5.5.0
Host:    Linux testing-worker-linux-3-1-22356-linux-15-13846335 2.6.32-042stab079.5 #1 SMP Fri Aug 2 17:16:15 MSK 2013 x86_64
Profile: Blank input "" / 1000 times
Class:   Markbench\Profile\BlankInputProfile

+----------------------+---------+---------+---------------+---------+--------------+
| package              | version | dialect | duration (MS) | MEM (B) | PEAK MEM (B) |
+----------------------+---------+---------+---------------+---------+--------------+
| erusev/parsedown     | 0.4.6   |         | 39            | 7340032 | 7340032      |
| michelf/php-markdown | 1.3     |         | 212           | 7864320 | 7864320      |
| michelf/php-markdown | 1.3     | extra   | 252           | 7864320 | 7864320      |
| kzykhys/ciconia      | v0.1.4  |         | 1100          | 8126464 | 8126464      |
| kzykhys/ciconia      | v0.1.4  | gfm     | 1183          | 8126464 | 8126464      |
+----------------------+---------+---------+---------------+---------+--------------+
$ php bin/markbench benchmark --profile=default
Runtime: PHP5.5.0
Host:    Linux testing-worker-linux-3-1-22356-linux-15-13846335 2.6.32-042stab079.5 #1 SMP Fri Aug 2 17:16:15 MSK 2013 x86_64
Profile: Basic markdown content with all official syntax / 1000 times
Class:   Markbench\Profile\DefaultProfile

+----------------------+---------+---------+---------------+---------+--------------+
| package              | version | dialect | duration (MS) | MEM (B) | PEAK MEM (B) |
+----------------------+---------+---------+---------------+---------+--------------+
| erusev/parsedown     | 0.4.6   |         | 4295          | 7602176 | 7864320      |
| michelf/php-markdown | 1.3     |         | 16650         | 8388608 | 8388608      |
| michelf/php-markdown | 1.3     | extra   | 21943         | 8126464 | 8126464      |
| kzykhys/ciconia      | v0.1.4  |         | 41148         | 8388608 | 8650752      |
| kzykhys/ciconia      | v0.1.4  | gfm     | 47341         | 8650752 | 8912896      |
+----------------------+---------+---------+---------------+---------+--------------+
$ php bin/markbench benchmark --profile=github-sample
Runtime: PHP5.5.0
Host:    Linux testing-worker-linux-3-1-22356-linux-15-13846335 2.6.32-042stab079.5 #1 SMP Fri Aug 2 17:16:15 MSK 2013 x86_64
Profile: Sample content from Github (http://github.github.com/github-flavored-markdown/sample_content.html) / 1000 times
Class:   Markbench\Profile\GithubSampleProfile

+----------------------+---------+---------+---------------+---------+--------------+
| package              | version | dialect | duration (MS) | MEM (B) | PEAK MEM (B) |
+----------------------+---------+---------+---------------+---------+--------------+
| erusev/parsedown     | 0.4.6   |         | 4599          | 7602176 | 7602176      |
| michelf/php-markdown | 1.3     |         | 15192         | 8388608 | 8388608      |
| michelf/php-markdown | 1.3     | extra   | 22031         | 8388608 | 8650752      |
| kzykhys/ciconia      | v0.1.4  |         | 41893         | 8650752 | 8912896      |
| kzykhys/ciconia      | v0.1.4  | gfm     | 48511         | 8912896 | 9175040      |
+----------------------+---------+---------+---------------+---------+--------------+

Comparison

erusev/parsedown

  • fast. (I've not checked the output)
  • It is a good option if you prefer to handle large number of markdown files.

michelf/php-markdown

  • A well-known library having many testers.
  • Great extra features.

kzykhys/ciconia

  • slow.
  • Github Flavord Markdown support
  • It is a good option if you prefer to customize the parser.

Conclusion

It is no surprise to me that performance of ciconia is not good. There are trade-offs between extensibility and performance.

comments powered by Disqus