Permalink
Browse files

use benchmarks-ips

  • Loading branch information...
1 parent a308d5d commit 6f8acb8bc892f6ae1abdce544427eb8a04ecbdc2 @minad minad committed Dec 5, 2014
Showing with 10 additions and 13 deletions.
  1. +2 −2 .travis.yml
  2. +1 −0 Gemfile
  3. +2 −2 Rakefile
  4. +5 −9 benchmarks/run-benchmarks.rb
View
@@ -25,8 +25,8 @@ env:
- "TASK=test:sinatra SINATRA=master"
- "TASK=test:sinatra SINATRA=1.3.6"
- "TASK=test:sinatra SINATRA=1.4.5"
- - "TASK=bench iterations=10000"
- - "TASK=bench slow=1 iterations=1000"
+ - "TASK=bench"
+ - "TASK=bench slow=1"
matrix:
exclude:
View
@@ -48,6 +48,7 @@ gem 'asciidoctor'
gem 'org-ruby'
if ENV['TASK'] == 'bench'
+ gem 'benchmark-ips'
gem 'erubis'
gem 'haml'
end
View
@@ -6,8 +6,8 @@ end
require 'rake/testtask'
-desc 'Run Slim benchmarks! (default parameters slow=false iterations=1000)'
-task :bench, :iterations, :slow do
+desc 'Run Slim benchmarks! (default parameters slow=false)'
+task :bench, :slow do
ruby('benchmarks/run-benchmarks.rb')
end
@@ -5,15 +5,14 @@
require 'slim'
require 'context'
-require 'benchmark'
+require 'benchmark/ips'
require 'tilt'
require 'erubis'
require 'erb'
require 'haml'
class SlimBenchmarks
- def initialize(slow, iterations)
- @iterations = (iterations || 1000).to_i
+ def initialize(slow)
@benches = []
@erb_code = File.read(File.dirname(__FILE__) + '/view.erb')
@@ -90,12 +89,9 @@ def init_parsing_benches
end
def run
- puts "#{@iterations} Iterations"
- Benchmark.bmbm do |x|
+ Benchmark.ips do |x|
@benches.each do |name, block|
- x.report name.to_s do
- @iterations.to_i.times { block.call }
- end
+ x.report(name.to_s, &block)
end
end
puts "
@@ -123,4 +119,4 @@ def bench(name, &block)
end
end
-SlimBenchmarks.new(ENV['slow'], ENV['iterations']).run
+SlimBenchmarks.new(ENV['slow']).run

0 comments on commit 6f8acb8

Please sign in to comment.