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