Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use the benchmark-ips gem for benchmarking

Instead of relying on the provided benchmark module, let's rely on the
benchmark-ips gem.

Since Kramdown is slow (~ 6 minutes to parse 10 thousands time the same
document), this is now a lot more easy to have feedback plus the
feedback is more useful because we have the amount of variation.
  • Loading branch information...
commit 4545b0e9c6e387e375a9fcba542f1ac56f73926c 1 parent 9742686
@robin850 robin850 authored
Showing with 7 additions and 8 deletions.
  1. +1 −0  Gemfile
  2. +6 −8 test/benchmark.rb
View
1  Gemfile
@@ -3,6 +3,7 @@ source "https://rubygems.org/"
gemspec
group :benchmark do
+ gem "benchmark-ips", "~> 1.2.0"
gem "bluecloth", "~> 2.2.0"
gem "kramdown", "~> 1.0.2"
end
View
14 test/benchmark.rb
@@ -1,26 +1,24 @@
# coding: UTF-8
# Thanks Kramdown for the inspiration!
-require "benchmark"
-require "stringio"
+require 'benchmark/ips'
require 'redcarpet'
require 'bluecloth'
require 'kramdown'
-TEST = 10_000
-m = File.read(File.join(File.dirname(__FILE__), "fixtures/benchmark.md"))
+markdown = File.read(File.join(File.dirname(__FILE__), "fixtures/benchmark.md"))
# Let's bench!
-Benchmark.bm do |bench|
+Benchmark.ips do |bench|
bench.report("Redcarpet") do
- TEST.times { Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(m) }
+ Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(markdown)
end
bench.report("BlueCloth") do
- TEST.times { BlueCloth.new(m).to_html }
+ BlueCloth.new(markdown).to_html
end
bench.report("Kramdown") do
- TEST.times { Kramdown::Document.new(m).to_html }
+ Kramdown::Document.new(markdown).to_html
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.