Skip to content

Instantly share code, notes, and snippets.

@meagar
Created December 1, 2020 15:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meagar/64fd28a15c4f15a135ad863bd35d5f6d to your computer and use it in GitHub Desktop.
Save meagar/64fd28a15c4f15a135ad863bd35d5f6d to your computer and use it in GitHub Desktop.
Monotonic time for benchmarking
# 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