From a74d40f1e55e058d1defbf22dba26c9734fc3b01 Mon Sep 17 00:00:00 2001 From: Florian Weingarten Date: Mon, 28 Jul 2014 20:33:30 +0000 Subject: [PATCH] benchmark/ips --- Gemfile | 1 + performance/benchmark.rb | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 13933d99..29524192 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,5 @@ gem 'stackprof', platforms: :mri_21 group :test do gem 'spy', '0.4.1' + gem 'benchmark-ips' end diff --git a/performance/benchmark.rb b/performance/benchmark.rb index cc990eb5..98c3985e 100644 --- a/performance/benchmark.rb +++ b/performance/benchmark.rb @@ -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