Class: Vizsla::Timer
- Inherits:
-
Object
- Object
- Vizsla::Timer
- Defined in:
- lib/vizsla/timer.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
- #collect_events ⇒ Object
- #elapsed ⇒ Object
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
- #start! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
7 8 9 10 |
# File 'lib/vizsla/timer.rb', line 7 def initialize @start_time = nil @stop_time = nil end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
5 6 7 |
# File 'lib/vizsla/timer.rb', line 5 def events @events end |
Instance Method Details
#collect_events ⇒ Object
23 24 25 |
# File 'lib/vizsla/timer.rb', line 23 def collect_events @events = Recorder.events end |
#elapsed ⇒ Object
27 28 29 |
# File 'lib/vizsla/timer.rb', line 27 def elapsed "#{(@stop_time - @start_time).round 2}s" end |
#start! ⇒ Object
12 13 14 15 |
# File 'lib/vizsla/timer.rb', line 12 def start! @start_time = Time.now Recorder.start_recording end |
#stop! ⇒ Object
17 18 19 20 21 |
# File 'lib/vizsla/timer.rb', line 17 def stop! collect_events Recorder.stop_recording @stop_time = Time.now end |