Created
December 28, 2016 16:30
-
-
Save ebeigarts/62547c525b5a452de5dc95915610d5a2 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
if Rails.env.development? | |
ActionView::PathSet.class_eval do | |
private | |
alias_method :__find_all, :_find_all | |
def _find_all(*args) | |
t1 = Time.now | |
__find_all(*args) | |
ensure | |
t2 = Time.now | |
Thread.current["find_template_time"] ||= 0 | |
Thread.current["find_template_time"] += (t2 - t1) * 1000 | |
end | |
end | |
module TemplateResolverControllerRuntime | |
extend ActiveSupport::Concern | |
private | |
def process_action(action, *args) | |
Thread.current["find_template_time"] = 0 | |
super | |
end | |
def append_info_to_payload(payload) | |
super | |
payload[:find_template_time] = Thread.current["find_template_time"] || 0 | |
Thread.current["find_template_time"] = 0 | |
end | |
module ClassMethods # :nodoc: | |
def log_process_action(payload) | |
messages, find_template_time = super, payload[:find_template_time] | |
messages << ("Resolver: %.1fms" % find_template_time.to_f) if find_template_time | |
messages | |
end | |
end | |
end | |
ActiveSupport.on_load(:action_controller) do | |
include TemplateResolverControllerRuntime | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment