class Async::Clock
def self.measure
def self.measure start_time = self.now yield return self.now - start_time end
def self.now
def self.now ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end
def self.start
def self.start self.new.tap(&:start!) end
def initialize(total = 0)
def initialize(total = 0) @total = total @started = nil end
def start!
def start! @started ||= Clock.now end
def stop!
def stop! if @started @total += (Clock.now - @started) @started = nil end return @total end
def total
def total total = @total if @started total += (Clock.now - @started) end return total end