class NewRelic::Shoes::Reporter
Constants
- HEADER
Public Instance Methods
append_to_results(metrics, results)
click to toggle source
# File lib/newrelic/shoes/reporter.rb, line 14 def append_to_results(metrics, results) results.concat(metrics.map do |spec, stats| [ spec.name, stats.call_count.to_s, stats.total_call_time.round(6).to_s, stats.total_exclusive_time.round(6).to_s, ips_from_stats(stats).round.to_s ] end) end
ips_from_stats(stats)
click to toggle source
# File lib/newrelic/shoes/reporter.rb, line 26 def ips_from_stats(stats) if stats.total_call_time > 0 && stats.call_count > 0 (1.0/(stats.total_call_time/stats.call_count)) else 0.0 end end
max_width_from(results)
click to toggle source
# File lib/newrelic/shoes/reporter.rb, line 34 def max_width_from(results) results.inject([]) do |memo, row| row.each_with_index do |column, index| if memo[index].nil? || memo[index] < column.length memo[index] = column.length end end memo end end
print_results(io, results, max_width)
click to toggle source
# File lib/newrelic/shoes/reporter.rb, line 45 def print_results(io, results, max_width) results.each do |row| row.each_with_index do |column, index| io.print column io.print " " * (max_width[index] - column.length + 2) end io.print "\n" end end
report(io=STDOUT)
click to toggle source
# File lib/newrelic/shoes/reporter.rb, line 5 def report(io=STDOUT) metrics = NewRelic::Agent.instance.stats_engine.harvest! results = [HEADER] append_to_results(metrics, results) max_width = max_width_from(results) print_results(io, results, max_width) end