Class: TraceTree::Timer
- Inherits:
-
Object
- Object
- TraceTree::Timer
- Defined in:
- lib/trace_tree/timer.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
6 7 8 9 10 |
# File 'lib/trace_tree/timer.rb', line 6 def initialize @record = Hash.new do |h, k| h[k] = [] end end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
4 5 6 |
# File 'lib/trace_tree/timer.rb', line 4 def record @record end |
Instance Method Details
#[](name) ⇒ Object
12 13 14 |
# File 'lib/trace_tree/timer.rb', line 12 def [](name) record[name] << Time.now end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/trace_tree/timer.rb', line 16 def to_s Hash[record.map{|k,v| [k, v[-1] - v[0]]}].to_s end |