Skip to content

Instantly share code, notes, and snippets.

@wangjohn
Created May 8, 2013 18:43
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 wangjohn/5542610 to your computer and use it in GitHub Desktop.
Save wangjohn/5542610 to your computer and use it in GitHub Desktop.
Benchmark for define_model_callbacks
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