Benchmarking the pure-ruby version of the parser, which is a new
option in 4.2…
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.2.0 compiled in Ruby…
Finished in 30.703538 seconds
30 seconds is a long time compared to…
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 3.0.4 compiled in ruby-regex…
Finished in 0.346966 seconds
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.0.0 compiled in C…
Finished in 0.055147 seconds
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.1.1 compiled in C…
Finished in 0.05756 seconds
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.1.9 compiled in C…
Finished in 0.140867 seconds
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.2.0 compiled in C…
Finished in 0.13385 seconds
Uh, yeah. I knew it was slow, but until now I had no idea it was
that slow compared to 3.0.4. The tests in 3.0.4 took a long time to
run, so I just figured the two all-ruby versions would be about the
same. Now that I think about it, it does make sense that even lots of
Regexes would be faster than doing all the looping, character
comparison, and concatenation in Ruby.
Also note that RedCloth has been getting slower with each version,
except this last one where I tried hard to reduce complexity in some
areas. Fixing bugs usually means making the machine more specific,
which means more complexity. The parser binary has more than doubled
in size since 4.0.0.
Let’s see about Ruby 1.8 vs 1.9…
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 3.0.4 compiled in ruby-regex…
Finished in 0.320067 seconds
~/Documents/redcloth(master) $ spec19 spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 3.0.4 compiled in ruby-regex…
Finished in 0.566467 seconds
So 3.0.4 is slower in Ruby 1.9. Interesting. Is 4.2.0?
~/Documents/redcloth(master) $ spec spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.2.0 compiled in C…
Finished in 0.148924 seconds
~/Documents/redcloth(master) $ spec19 spec/benchmark_spec.rb -O spec/
spec.opts
Benchmarking version 4.2.0 compiled in C…
Finished in 0.107696 seconds
Thankfully, no.
My conclusion is, I need to do something different with RedCloth in
the long term if I want it available as a pure-Ruby library and if I
don’t want the size and parse time to keep ballooning.
Jason