free_mutant/lib/mutant/timer.rb
2018-11-25 21:43:35 +00:00

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