Class: Monotonic::Timer
- Inherits:
-
Object
- Object
- Monotonic::Timer
- Defined in:
- lib/Monotonic/Timer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#start ⇒ Object
class << self.
- #stop ⇒ Object
- #time ⇒ Object
- #total_time ⇒ Object
Class Method Details
.time(&block) ⇒ Object
9 10 11 12 |
# File 'lib/Monotonic/Timer.rb', line 9 def time(&block) timer = Timer.new timer.time(&block) end |
Instance Method Details
#start ⇒ Object
class << self
15 16 17 18 |
# File 'lib/Monotonic/Timer.rb', line 15 def start @finish_time = nil @start_time = Monotonic::Time.now end |
#stop ⇒ Object
20 21 22 |
# File 'lib/Monotonic/Timer.rb', line 20 def stop @finish_time = Monotonic::Time.now end |
#time ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/Monotonic/Timer.rb', line 32 def time start begin yield self ensure stop end total_time end |