Skip to content

Instantly share code, notes, and snippets.

@fjfish
Created April 20, 2024 10:23
Show Gist options
  • Save fjfish/6c3599c4ef0f7e2c62a12fd69ac020da to your computer and use it in GitHub Desktop.
Save fjfish/6c3599c4ef0f7e2c62a12fd69ac020da to your computer and use it in GitHub Desktop.
Timer wrapper if you want to time something
def timer(id)
start_time = Time.zone.now
result = yield
elapsed_time = Time.zone.now - start_time
puts "Find #{id} Execution time: #{elapsed_time.round(2)}s"
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment