diff --git a/Gemfile b/Gemfile index f8c6470..1b41843 100644 --- a/Gemfile +++ b/Gemfile @@ -6,12 +6,13 @@ source 'https://rubygems.org' gemspec group :test, :development do - gem 'appraisal', '~> 2.2' - gem 'coveralls', '>= 0.7.0', require: false - gem 'pry', '>= 0.10.0' - gem 'rake', '>= 10.0' - gem 'rspec-rails', '>= 3.6.0' - gem 'rubocop', '>= 0.41' - gem 'simplecov', '>= 0.14.0', require: false - gem 'yardstick', '>= 0.9.0' + gem 'appraisal', '~> 2.2' + gem 'benchmark-ips', '~> 2.0', '>= 2.7.2' + gem 'coveralls', '>= 0.7.0', require: false + gem 'pry', '>= 0.10.0' + gem 'rake', '>= 10.0' + gem 'rspec-rails', '>= 3.6.0' + gem 'rubocop', '>= 0.41' + gem 'simplecov', '>= 0.14.0', require: false + gem 'yardstick', '>= 0.9.0' end diff --git a/benchmarks/allowable.rb b/benchmarks/allowable.rb index 8bb707c..72c61f6 100644 --- a/benchmarks/allowable.rb +++ b/benchmarks/allowable.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'benchmark' require 'bundler/setup' +require 'benchmark/ips' require 'allowable' require 'action_controller' @@ -12,7 +12,7 @@ hash = {} allow_filters = {} -1_000_000.times do |n| +100.times do |n| hash[n] = n allow_filters[n] = n + 1 end @@ -21,7 +21,7 @@ params = ActionController::Parameters.new(hash) -Benchmark.bmbm do |bm| +Benchmark.ips do |bm| bm.report('Hash#allow') { hash.allow(allow_filters) } bm.report('Hash#forbid') { hash.forbid(forbid_filters) } @@ -32,4 +32,6 @@ bm.report('ActionController::Parameters#forbid') do params.forbid(forbid_filters) end + + bm.compare! end