Class: XRayMachine::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/x_ray_machine/summary.rb

Defined Under Namespace

Modules: Runtime

Class Method Summary collapse

Class Method Details

.add(payload) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/x_ray_machine/summary.rb', line 3

def self.add(payload)
  payload_sum = XRayMachine::LogSubscriber.runtimes.map{|k,v| v}.inject(0){|a,b| a+b}

  # most of the times things are lazyloaded
  if payload[:view_runtime] && payload[:view_runtime] > payload_sum
    payload[:view_runtime] -= payload_sum
  end
end

.messagesObject



12
13
14
15
16
17
18
19
# File 'lib/x_ray_machine/summary.rb', line 12

def self.messages
  XRayMachine::LogSubscriber.runtimes.map do |stream_name, duration|
    stream = XRayMachine::Config.for(stream_name)
    if stream.show_in_summary?
      "%s: %.1fms" % [stream.title, duration]
    end
  end.compact
end