Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby Markdown parser libraries benchmark
%w[rubygems open-uri benchmark kramdown bluecloth maruku rdiscount].each do |lib|
require lib
end
n = 1000
md = open('http://maruku.rubyforge.org/maruku.md').read
def parse_md(parser, md)
parser.new(md).to_html
end
Benchmark.bm 15 do |x|
x.report("Maruku") { n.times { parse_md Maruku, md } }
x.report("Kramdown") { n.times { parse_md Kramdown::Document, md } }
x.report("Bluecloth") { n.times { parse_md BlueCloth, md } }
x.report("RDiscount") { n.times { parse_md RDiscount, md } }
end
% ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
% ruby markdown-benchmark.rb
user system total real
Maruku 72.230000 0.950000 73.180000 ( 73.231086)
Kramdown 31.310000 0.290000 31.600000 ( 31.708552)
Bluecloth 0.910000 0.020000 0.930000 ( 0.921067)
RDiscount 0.490000 0.000000 0.490000 ( 0.496885)
% ruby -v
rubinius 1.2.4 (1.8.7 release 2011-07-05 JI) [x86_64-apple-darwin11.4.0]
% ruby markdown-benchmark.rb
user system total real
Maruku 133.589676 0.377935 133.967611 (125.178804)
Kramdown 92.103726 0.169284 92.273010 ( 89.951820)
Bluecloth 0.530919 0.009140 0.540059 ( 0.532022)
RDiscount 0.481381 0.001117 0.482498 ( 0.482841)
% ruby -v
rubinius 2.0.0dev (1.8.7 73298786 yyyy-mm-dd JI) [x86_64-apple-darwin11.4.0]
% ruby markdown-benchmark.rb
user system total real
Maruku 128.114079 0.622055 128.736134 (117.085048)
Kramdown 123.552663 0.334006 123.886669 (119.782310)
Bluecloth 0.708629 0.004557 0.713186 ( 0.708668)
RDiscount 0.839977 0.002308 0.842285 ( 0.859429)
% ruby -v
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]
% ruby markdown-benchmark.rb
user system total real
Maruku 93.493000 0.000000 93.493000 ( 93.494000)
Kramdown 30.954000 0.000000 30.954000 ( 30.954000)
Bluecloth 1.028000 0.000000 1.028000 ( 1.028000)
RDiscount 1.077000 0.000000 1.077000 ( 1.077000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.