Module: Cogger::Time

Defined in:
lib/cogger/time/span.rb,
lib/cogger/time/unit.rb,
lib/cogger/time/clock.rb,
lib/cogger/time/range.rb

Defined Under Namespace

Classes: Span

Constant Summary collapse

Unit =

Provides unit of measure for duration.

lambda do |duration, range: RANGE|
  case duration
    when range.fetch(:nanoseconds) then "ns"
    when range.fetch(:microseconds) then "µs"
    when range.fetch(:milliseconds) then "ms"
    when range.fetch(:seconds) then "s"
    else "m"
  end
end
Clock =

An adapter for acquiring current time.

-> id = Process::CLOCK_MONOTONIC, unit: :nanosecond { Process.clock_gettime id, unit }
RANGE =
{
  nanoseconds: ...1_000,
  microseconds: 1_000...1_000_000,
  milliseconds: 1_000_000...1_000_000_000,
  seconds: 1_000_000_000...60_000_000_000,
  minutes: 60_000_000_000...
}.freeze