Module: Rex::Stopwatch
- Defined in:
- lib/rex/stopwatch.rb
Class Method Summary collapse
-
.elapsed_time(unit: :float_second) { ... } ⇒ Object
This provides a correct way to time an operation provided within a block.
Class Method Details
.elapsed_time(unit: :float_second) { ... } ⇒ Object
This provides a correct way to time an operation provided within a block.
15 16 17 18 19 20 21 |
# File 'lib/rex/stopwatch.rb', line 15 def self.elapsed_time(unit: :float_second) start = Process.clock_gettime(Process::CLOCK_MONOTONIC, unit) ret = yield elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC, unit) - start [ret, elapsed] end |