Skip to content

Instantly share code, notes, and snippets.

@thieso2
Created February 23, 2010 07:45
Show Gist options
  • Save thieso2/311980 to your computer and use it in GitHub Desktop.
Save thieso2/311980 to your computer and use it in GitHub Desktop.
Show require calls with timing
require 'benchmark'
$require_level = 0
module Kernel
alias require_without_timing require
def require(path)
result = seconds = nil
begin
$require_level += 1
seconds = Benchmark.realtime { result = require_without_timing(path) }
ensure
$require_level -= 1
end
puts "#{'%.5f' % seconds} #{' '*$require_level}#{path}" if result
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment