Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created October 16, 2018 17:54
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 havenwood/72434aba0785bd915942898b42fd3175 to your computer and use it in GitHub Desktop.
Save havenwood/72434aba0785bd915942898b42fd3175 to your computer and use it in GitHub Desktop.
module Benchmark
module_function def orbyt unit: :nanosecond
start_time = Process.clock_gettime Process::CLOCK_MONOTONIC, unit
yield
end_time = Process.clock_gettime Process::CLOCK_MONOTONIC, unit
"#{end_time - start_time} #{unit}s"
end
end
Benchmark.orbyt { 'orbyt' == 'orbyt' }
#=> "65138 nanoseconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment