Created
July 19, 2018 09:26
-
-
Save Irostovsky/52e2e17784ba45d64bc6098c313b794b to your computer and use it in GitHub Desktop.
Bench timer
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
# frozen_string_literal: true | |
module Utils | |
class Timer | |
def self.call(name) | |
t = Time.zone.now | |
result = yield | |
time = ((Time.zone.now - t).to_d * 1000).to_i | |
p "++++++++++ #{name}: #{time}ms" | |
{ result: result, time: time } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use: