Skip to content

Instantly share code, notes, and snippets.

@olbat
Last active November 10, 2017 10:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save olbat/c8a27450facadf1423446e790cad75a4 to your computer and use it in GitHub Desktop.
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