Created
February 23, 2010 07:45
-
-
Save thieso2/311980 to your computer and use it in GitHub Desktop.
Show require calls with timing
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
| 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