Skip to content

Instantly share code, notes, and snippets.

@olbat olbat/time_measure.rb
Last active Nov 10, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.