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
11 12 13 14 |
# File 'lib/Monotonic/Timer.rb', line 11 def time(&block) timer = Timer.new timer.time(&block) end |
Instance Method Details
#start ⇒ Object
class << self
18 19 20 21 |
# File 'lib/Monotonic/Timer.rb', line 18 def start @finish_time = nil @start_time = Monotonic::Time.now end |
#stop ⇒ Object
23 24 25 |
# File 'lib/Monotonic/Timer.rb', line 23 def stop @finish_time = Monotonic::Time.now end |
#time ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/Monotonic/Timer.rb', line 35 def time start yield self ensure stop return total_time end |