Class: Rack::Bug::SpeedTrace::TraceRecord
- Inherits:
-
Object
- Object
- Rack::Bug::SpeedTrace::TraceRecord
show all
- Includes:
- Render
- Defined in:
- lib/rack/bug/panels/speedtracer_panel/tracer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Render
#compiled_source
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Constructor Details
Returns a new instance of TraceRecord.
5
6
7
8
9
|
# File 'lib/rack/bug/panels/speedtracer_panel/tracer.rb', line 5
def initialize(id)
@id = id
@start = Time.now
@children = []
end
|
Instance Attribute Details
#start ⇒ Object
Returns the value of attribute start.
11
12
13
|
# File 'lib/rack/bug/panels/speedtracer_panel/tracer.rb', line 11
def start
@start
end
|
Instance Method Details
#duration ⇒ Object
23
24
25
|
# File 'lib/rack/bug/panels/speedtracer_panel/tracer.rb', line 23
def duration
((@finish - @start) * 1000).to_i
end
|
#finish ⇒ Object
13
14
15
|
# File 'lib/rack/bug/panels/speedtracer_panel/tracer.rb', line 13
def finish
@finish ||= Time.now
end
|
#time_in_children ⇒ Object
17
18
19
20
21
|
# File 'lib/rack/bug/panels/speedtracer_panel/tracer.rb', line 17
def time_in_children
@children.inject(0) do |time, child|
time + child.duration
end
end
|
#to_json ⇒ Object
27
28
29
|
# File 'lib/rack/bug/panels/speedtracer_panel/tracer.rb', line 27
def to_json
Yajl::Encoder.encode(hash_representation, :pretty => true, :indent => ' ')
end
|