Class: Rack::Bug::SpeedTrace::TraceRecord
- Inherits:
-
Object
- Object
- Rack::Bug::SpeedTrace::TraceRecord
- Includes:
- Render
- Defined in:
- lib/rack/bug/speedtracer/tracer.rb
Direct Known Subclasses
Instance Method Summary collapse
- #duration ⇒ Object
- #finish ⇒ Object
-
#initialize(id) ⇒ TraceRecord
constructor
A new instance of TraceRecord.
- #time_in_children ⇒ Object
- #to_json ⇒ Object
Methods included from Render
Constructor Details
#initialize(id) ⇒ TraceRecord
Returns a new instance of TraceRecord.
7 8 9 10 11 |
# File 'lib/rack/bug/speedtracer/tracer.rb', line 7 def initialize(id) @id = id @start = Time.now @children = [] end |
Instance Method Details
#duration ⇒ Object
21 22 23 |
# File 'lib/rack/bug/speedtracer/tracer.rb', line 21 def duration ((@finish - @start) * 1000).to_i end |
#finish ⇒ Object
13 |
# File 'lib/rack/bug/speedtracer/tracer.rb', line 13 def finish; @finish = Time.now; end |
#time_in_children ⇒ Object
15 16 17 18 19 |
# File 'lib/rack/bug/speedtracer/tracer.rb', line 15 def time_in_children @children.inject(0) do |time, child| time + child.duration end end |
#to_json ⇒ Object
25 26 27 |
# File 'lib/rack/bug/speedtracer/tracer.rb', line 25 def to_json Yajl::Encoder.encode(hash_representation, :pretty => true, :indent => ' ') end |