Created
May 8, 2013 18:43
-
-
Save wangjohn/5542610 to your computer and use it in GitHub Desktop.
Benchmark for define_model_callbacks
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
require 'active_model' | |
require 'benchmark' | |
class Post | |
extend ActiveModel::Callbacks | |
define_model_callbacks :make | |
def make | |
run_callbacks :make do | |
end | |
end | |
end | |
NUM_TRIALS = [10, 50, 500, 1000, 10000, 50000] | |
Benchmark.bm(13) do |x| | |
NUM_TRIALS.each do |trials| | |
x.report("#{trials} trials") do | |
trials.times do | |
Post.define_model_callbacks :make | |
end | |
end | |
end | |
end· |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment