Created
February 20, 2024 22:22
-
-
Save exterm/a915f6cd51f4a9a8d6c9f893965436fc to your computer and use it in GitHub Desktop.
Profile requires on rails application startup
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
# add to config/boot.rb | |
require "benchmark" | |
$require_nesting = -1 | |
def require(file_name) | |
result = nil | |
$require_nesting += 1 | |
time = Benchmark.realtime do | |
result = super | |
end | |
if result | |
if time > 0.2 | |
indentation = "=" * $require_nesting | |
puts indentation + "> #{time} #{file_name}" | |
# else | |
# indentation = "-" * $require_nesting | |
# puts indentation + "> #{time} #{file_name}" | |
end | |
end | |
$require_nesting -= 1 | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment