-
-
Save iaankrynauw/e62f1b0bdeed591572b6d7316b2b1daa to your computer and use it in GitHub Desktop.
profiling rails initializers
This file contains hidden or 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
| # bundle open railties | |
| # 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