-
-
Notifications
You must be signed in to change notification settings - Fork 90
Closed
Labels
Description
Not sure if it's commonmarker or underlying lib issue, but still.
Highly scientific benchmark
Benchmark.ips do |x|
10.times do |n|
x.report("commonmarker_render_html #{n}") do
CommonMarker.render_html(text, :DEFAULT, [:autolink])
end
x.report("commonmarker_two_step #{n}") do
parsed_doc = CommonMarker.render_doc(text, :DEFAULT, [:autolink])
parsed_doc.to_html(:DEFAULT, [:autolink])
end
end
x.compare!
end
where text
is README.md
from this repo shows
Comparison:
commonmarker_two_step 7: 6766.2 i/s
commonmarker_two_step 2: 6753.3 i/s - same-ish: difference falls within error
commonmarker_two_step 8: 6748.9 i/s - same-ish: difference falls within error
commonmarker_two_step 5: 6725.9 i/s - same-ish: difference falls within error
commonmarker_two_step 6: 6720.3 i/s - same-ish: difference falls within error
commonmarker_two_step 1: 6720.3 i/s - same-ish: difference falls within error
commonmarker_two_step 4: 6705.3 i/s - same-ish: difference falls within error
commonmarker_two_step 0: 6703.2 i/s - same-ish: difference falls within error
commonmarker_two_step 9: 6664.8 i/s - same-ish: difference falls within error
commonmarker_two_step 3: 6655.7 i/s - same-ish: difference falls within error
commonmarker_render_html 8: 2542.5 i/s - 2.66x (± 0.00) slower
commonmarker_render_html 7: 2519.9 i/s - 2.69x (± 0.00) slower
commonmarker_render_html 3: 2498.4 i/s - 2.71x (± 0.00) slower
commonmarker_render_html 0: 2492.0 i/s - 2.72x (± 0.00) slower
commonmarker_render_html 9: 2453.8 i/s - 2.76x (± 0.00) slower
commonmarker_render_html 2: 2429.4 i/s - 2.79x (± 0.00) slower
commonmarker_render_html 4: 2412.7 i/s - 2.80x (± 0.00) slower
commonmarker_render_html 6: 2391.4 i/s - 2.83x (± 0.00) slower
commonmarker_render_html 5: 2371.8 i/s - 2.85x (± 0.00) slower
commonmarker_render_html 1: 2363.0 i/s - 2.86x (± 0.00) slower
so we can easily speedup #render_html
2.5x times by using some more ruby, but I have a suspicion that it should be faster as is.