Last active
August 29, 2015 14:22
-
-
Save danlynn/40e3a94d39c26d9948fc to your computer and use it in GitHub Desktop.
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
require 'log4r' | |
def logger | |
@@logger ||= Logger.new("#{Rails.root}/log/some_profile.log") | |
end | |
def elapsed(start_time) | |
elapsed_secs = Time.now - start_time | |
"#{'%2d' % (elapsed_secs/60)}:#{'%02d' % (elapsed_secs%60)}:#{('%.4f' % (elapsed_secs - elapsed_secs.floor))[-4..-1]}" | |
end | |
def test_this_method | |
start_time = Time.now | |
# do some time consuming stuff... | |
logger.debug("Elapsed time to do stuff: #{elapsed(start_time)}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This generates output like:
which reads as 1 minute, 25 secs, 685 ten thousands.