Created
April 20, 2024 10:23
-
-
Save fjfish/6c3599c4ef0f7e2c62a12fd69ac020da to your computer and use it in GitHub Desktop.
Timer wrapper if you want to time something
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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