Module: Benchmark::Perf::Clock

Defined in:
lib/benchmark/perf/clock.rb

Overview

Clock that represents monotonic time

Constant Summary collapse

MICROSECONDS_PER_SECOND =

Microseconds per second

1_000_000
MICROSECONDS_PER_100MS =

Microseconds per 100ms

100_000

Class Method Summary collapse

Class Method Details

.measureFloat

Measure time elapsed with a monotonic clock

Returns:

  • (Float)


58
59
60
61
62
63
# File 'lib/benchmark/perf/clock.rb', line 58

def measure
  before = now
  yield
  after = now
  after - before
end

.nowFloat

Current monotonic time

Returns:

  • (Float)


48
49
50
# File 'lib/benchmark/perf/clock.rb', line 48

def now
  MONOTONIC_CLOCK.now
end