21 lines
377 B
Ruby
21 lines
377 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Mutant
|
|
module Timer
|
|
# Monotonic elapsed time of block execution
|
|
#
|
|
# @return [Float]
|
|
def self.elapsed
|
|
start = now
|
|
yield
|
|
now - start
|
|
end
|
|
|
|
# The now monotonic time
|
|
#
|
|
# @return [Float]
|
|
def self.now
|
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
end
|
|
end # Timer
|
|
end # Mutant
|