class Time

Constants

DEFAULT_STAMP
DEFAULT_UNIT
STAMPS
UNITS

Public Class Methods

elapse(verbose: false) { || ... } click to toggle source
# File lib/lite/ruby/time.rb, line 25
def elapse(verbose: false)
  started_at = monotonic
  yield
  ended_at = monotonic
  runtime = ended_at - started_at
  return runtime unless verbose

  { started_at: started_at, ended_at: ended_at, runtime: runtime }
end
monotonic() click to toggle source
# File lib/lite/ruby/time.rb, line 35
def monotonic
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end