Created
July 13, 2012 21:46
-
-
Save ssoroka/3107754 to your computer and use it in GitHub Desktop.
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
# insert at the top of boot.rb for FUN! | |
require 'benchmark' | |
$level ||= 0 | |
$file ||= File.open('require_tree.log', 'w') | |
$pending_writes = [] | |
Object.class_eval do | |
def __trace_requires(arg, &block) | |
val = nil | |
time = nil | |
$pending_writes << [$level, arg] | |
$level += 1 | |
begin | |
time = Benchmark.realtime { | |
val = block.call | |
} | |
rescue LoadError | |
$level -= 1 | |
$pending_writes.pop | |
raise | |
end | |
$level -= 1 | |
lvl, method = $pending_writes.pop | |
if time >= 0.2 | |
if lvl | |
$pending_writes.each do |l, m| | |
$file.write (' ' * l) << '-> ' << m << "\n" | |
end | |
$pending_writes = [] | |
if method == arg && lvl == $level | |
$file.write (' ' * $level) << "<> #{time.round(2)}s " << arg << "\n" | |
end | |
else | |
$file.write (' ' * $level) << "<- #{time.round(2)}s " << arg << "\n" | |
end | |
$file.flush | |
end | |
val | |
end | |
def require_relative(arg) | |
__trace_requires(arg) do | |
super | |
end | |
end | |
def require(arg) | |
__trace_requires(arg) do | |
super | |
end | |
end | |
end |
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
<> 0.81s bundler/setup | |
-> rails/commands | |
-> rails/commands/runner | |
-> /Users/steven/Projects/shopify/config/application | |
-> rails/all | |
<> 0.27s active_record/railtie | |
<- 0.47s rails/all | |
<> 0.28s active_merchant | |
<> 0.22s shopify_api/json_format | |
-> /Users/steven/Projects/shopify/vendor/bundle/ruby/1.9.1/bundler/gems/opensrs-ac81565123a7/lib/opensrs/xml_processor/nokogiri.rb | |
<> 0.25s nokogiri | |
<- 0.25s /Users/steven/Projects/shopify/vendor/bundle/ruby/1.9.1/bundler/gems/opensrs-ac81565123a7/lib/opensrs/xml_processor/nokogiri.rb | |
-> openid | |
<> 0.21s openid/consumer | |
<- 0.23s openid | |
<> 0.24s redcloth/formatters/latex | |
<> 0.41s net/ssh | |
<> 0.3s nested_form/builder | |
-> newrelic_rpm | |
-> new_relic/control | |
<> 0.32s new_relic/agent | |
<- 0.53s new_relic/control | |
<- 0.53s newrelic_rpm | |
<> 0.36s sass/engine | |
<> 0.23s sprockets | |
<> 0.5s sprockets/extensions/rails/action_controller/base | |
<> 0.21s mongrel/handlers | |
<> 0.25s right_aws | |
<- 8.4s /Users/steven/Projects/shopify/config/application | |
-> /Users/steven/Projects/shopify/config/environment.rb | |
<> 0.43s mail | |
<> 1.31s /Users/steven/Projects/shopify/app/models/shop | |
-> /Users/steven/Projects/shopify/app/controllers/admin/account_setups_controller | |
-> /Users/steven/Projects/shopify/app/controllers/admin_area_controller | |
-> /Users/steven/Projects/shopify/app/controllers/application_controller | |
<> 0.21s /Users/steven/Projects/shopify/app/models/api_permission | |
<- 0.58s /Users/steven/Projects/shopify/app/controllers/application_controller | |
<- 0.69s /Users/steven/Projects/shopify/app/controllers/admin_area_controller | |
<- 0.7s /Users/steven/Projects/shopify/app/controllers/admin/account_setups_controller | |
<> 0.21s /Users/steven/Projects/shopify/app/controllers/services/partners/auth_controller | |
-> /Users/steven/Projects/shopify/app/models/collection_observer | |
<> 0.22s /Users/steven/Projects/shopify/app/models/product | |
<> 0.23s /Users/steven/Projects/shopify/app/models/order | |
<- 0.48s /Users/steven/Projects/shopify/app/models/collection_observer | |
<> 0.35s /Users/steven/Projects/shopify/app/models/country | |
<> 0.24s /Users/steven/Projects/shopify/app/models/domain | |
<- 20.44s /Users/steven/Projects/shopify/config/environment.rb | |
<- 28.83s rails/commands/runner | |
<- 28.84s rails/commands | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment