Class: Euston::Stopwatch
- Inherits:
-
Object
- Object
- Euston::Stopwatch
- Includes:
- Hollywood
- Defined in:
- lib/euston-daemons/euston/stopwatch.rb
Instance Method Summary collapse
Instance Method Details
#time(decimal_places = 3, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/euston-daemons/euston/stopwatch.rb', line 5 def time decimal_places = 3, &block start = Time.now.to_f result = yield block finish = Time.now.to_f elapsed = finish - start elapsed = elapsed.round(decimal_places) unless decimal_places.nil? callback :finished, elapsed result end |