benchmark/ips

This commit is contained in:
Florian Weingarten 2014-07-28 20:33:30 +00:00
parent 79d4ec1a48
commit a74d40f1e5
2 changed files with 12 additions and 5 deletions

View File

@ -5,4 +5,5 @@ gem 'stackprof', platforms: :mri_21
group :test do
gem 'spy', '0.4.1'
gem 'benchmark-ips'
end

View File

@ -1,11 +1,17 @@
require 'benchmark'
require 'benchmark/ips'
require File.dirname(__FILE__) + '/theme_runner'
Liquid::Template.error_mode = ARGV.first.to_sym if ARGV.first
profiler = ThemeRunner.new
Benchmark.bmbm do |x|
x.report("parse:") { 100.times { profiler.compile } }
x.report("parse & run:") { 100.times { profiler.run } }
end
Benchmark.ips do |x|
x.time = 60
x.warmup = 5
puts
puts "Running benchmark for #{x.time} seconds (with #{x.warmup} seconds warmup)."
puts
x.report("parse:") { profiler.compile }
x.report("parse & run:") { profiler.run }
end