Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Benchmark initializer load time
# place in railties/lib/rails/initializable.rb
def run_initializers(group=:default, *args)
return if instance_variable_defined?(:@ran)
t0 =
initializers.tsort.each do |initializer|
t =*args) if initializer.belongs_to?(group)
puts("%60s: %.3f sec" % [, - t])
puts "%60s: %.3f sec" % ["for all", - t0]
@ran = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment