Last active
November 10, 2017 10:18
-
-
Save olbat/c8a27450facadf1423446e790cad75a4 to your computer and use it in GitHub Desktop.
Ruby time measurement (monotonic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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