Skip to content

Instantly share code, notes, and snippets.

@max-power
Last active December 8, 2023 22:06
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 max-power/30abf44b3584f846d09d873c2ebb25d5 to your computer and use it in GitHub Desktop.
Save max-power/30abf44b3584f846d09d873c2ebb25d5 to your computer and use it in GitHub Desktop.
Simple timing functions. Include it or use as standalone module
module Timer
module_function
def time unit = :microsecond
Process.clock_gettime(Process::CLOCK_MONOTONIC, unit)
end
def time_it start = time
yield
time_diff start
end
def time_diff start, stop = time
((stop - start) / 1000.0).round
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment