Skip to content

Instantly share code, notes, and snippets.

@olegantonyan
Created August 13, 2018 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olegantonyan/735848cb0f188410ca3863de718e7c53 to your computer and use it in GitHub Desktop.
Save olegantonyan/735848cb0f188410ca3863de718e7c53 to your computer and use it in GitHub Desktop.
ruby monotonic timer benchmark
def benchmark(what)
start = ::Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield
finish = ::Process.clock_gettime(Process::CLOCK_MONOTONIC)
sap "#{what} took #{finish - start} seconds"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment