Skip to content

Commit

Permalink
use benchmark-ips
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed Aug 9, 2017
1 parent 9b0c94d commit d027722
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 9 additions & 8 deletions Gemfile
Expand Up @@ -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
8 changes: 5 additions & 3 deletions benchmarks/allowable.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'benchmark'
require 'bundler/setup'
require 'benchmark/ips'
require 'allowable'
require 'action_controller'

Expand All @@ -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
Expand All @@ -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) }

Expand All @@ -32,4 +32,6 @@
bm.report('ActionController::Parameters#forbid') do
params.forbid(forbid_filters)
end

bm.compare!
end

0 comments on commit d027722

Please sign in to comment.