Skip to content

Instantly share code, notes, and snippets.

@exterm
Created February 20, 2024 22:22
Show Gist options
  • Save exterm/a915f6cd51f4a9a8d6c9f893965436fc to your computer and use it in GitHub Desktop.
Save exterm/a915f6cd51f4a9a8d6c9f893965436fc to your computer and use it in GitHub Desktop.
Profile requires on rails application startup
# 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