|
@ -14,12 +14,9 @@ module Semantic |
|
|
def render_partial(event) |
|
|
def render_partial(event) |
|
|
identifier = pathname(event.payload[:identifier]) |
|
|
identifier = pathname(event.payload[:identifier]) |
|
|
partial_savings = @partials[event.transaction_id] ||= {} |
|
|
partial_savings = @partials[event.transaction_id] ||= {} |
|
|
partial_saving = partial_savings[identifier] ||= { |
|
|
|
|
|
# TODO: might be smarter: origins=[{caller:, count:}] |
|
|
|
|
|
count: 0, |
|
|
|
|
|
first_origin: Rails.backtrace_cleaner.clean(caller)[1] |
|
|
|
|
|
} |
|
|
|
|
|
partial_saving[:count] += 1 |
|
|
|
|
|
|
|
|
partial_saving = partial_savings[identifier] ||= {} |
|
|
|
|
|
origin = Rails.backtrace_cleaner.clean(caller)[1] # [0] is related to Instrumentalizer, get rid of it! |
|
|
|
|
|
partial_saving[origin] = partial_saving.key?(origin) ? partial_saving[origin] + 1 : 1 |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def render_template(event) |
|
|
def render_template(event) |
|
@ -61,10 +58,14 @@ module Semantic |
|
|
|
|
|
|
|
|
def pop_partial_savings(transaction_id) |
|
|
def pop_partial_savings(transaction_id) |
|
|
partial_savings = @partials.delete(transaction_id) |
|
|
partial_savings = @partials.delete(transaction_id) |
|
|
partial_savings.each do |partial, saving| |
|
|
|
|
|
count_info = " (#{saving[:count]} times)" if saving[:count] > 1 |
|
|
|
|
|
logger.debug("Rendered partial #{partial}#{count_info}") |
|
|
|
|
|
logger.debug(Semantic::Helper.stackisize(saving[:first_origin], symbol: '⇤')) |
|
|
|
|
|
|
|
|
partial_savings.each do |partial, origins| |
|
|
|
|
|
sum_count = origins.values.reduce(:+) |
|
|
|
|
|
sum_count_info = " (#{sum_count} times in total)" if sum_count > 1 |
|
|
|
|
|
logger.debug("Rendered partial #{partial}#{sum_count_info}") |
|
|
|
|
|
origins.each do |origin, count| |
|
|
|
|
|
count_info = colorize("(#{count} times)", TEXT_GRAY_400) if count > 1 |
|
|
|
|
|
logger.debug("#{Semantic::Helper.stackisize(origin, symbol: '⇤')}#{count_info}") |
|
|
|
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|