Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created March 14, 2012 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan/2036114 to your computer and use it in GitHub Desktop.
Save bogdan/2036114 to your computer and use it in GitHub Desktop.
load "/home/bogdan/bin/diffbench"
$LOAD_PATH << "./lib"
require "active_model"
class User
include ActiveModel::MassAssignmentSecurity
attr_protected :admin
public :sanitize_for_mass_assignment
end
u = User.new
amount = 100
DiffBench.bm do
report("when something sanitized") do
1000.times do
u.sanitize_for_mass_assignment(:admin => true, :hello => :hz)
end
end
report("when nothing sanitized") do
1000.times do
u.sanitize_for_mass_assignment(:hello => :hz)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment