Created
March 14, 2012 12:22
-
-
Save bogdan/2036114 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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