Class: Rack::Insight::SpeedTracer::TraceRecord

Inherits:
Object
  • Object
show all
Includes:
Render
Defined in:
lib/rack/insight/panels/speedtracer_panel/tracer.rb

Direct Known Subclasses

RequestRecord, ServerEvent

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Methods included from Logging

logger, verbose, verbosity

Constructor Details

#initializeTraceRecord

Returns a new instance of TraceRecord.



84
85
86
87
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 84

def initialize
  @start = Time.now
  @children = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



89
90
91
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 89

def children
  @children
end

#startObject (readonly)

Returns the value of attribute start.



90
91
92
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 90

def start
  @start
end

Instance Method Details

#durationObject



102
103
104
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 102

def duration
  ((@finish - @start) * 1000).to_i
end

#finishObject



92
93
94
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 92

def finish
  @finish ||= Time.now
end

#time_in_childrenObject



96
97
98
99
100
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 96

def time_in_children
  @children.inject(0) do |time, child|
    time + child.duration
  end
end

#to_jsonObject



106
107
108
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 106

def to_json
  Yajl::Encoder.encode(hash_representation, :pretty => true, :indent => '  ')
end