Skip to content

Instantly share code, notes, and snippets.

@olbat
Last active November 10, 2017 10:18
Ruby time measurement (monotonic)
module Time::Measure
refine Time.singleton_class do
def measure(&_block)
tstart = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield if block_given?
(Process.clock_gettime(Process::CLOCK_MONOTONIC) - tstart)
end
end
end
=begin
using Time::Measure
Time.measure{ sleep 1 }
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment