Created
December 1, 2020 15:00
-
-
Save meagar/64fd28a15c4f15a135ad863bd35d5f6d to your computer and use it in GitHub Desktop.
Monotonic time for benchmarking
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
# Source: https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/ | |
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
# time consuming operation | |
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
elapsed = ending - starting | |
elapsed # => 9.183449000120163 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment