Skip to content

Instantly share code, notes, and snippets.

@stevebartholomew
Created January 19, 2012 09:56
Show Gist options
  • Save stevebartholomew/1639128 to your computer and use it in GitHub Desktop.
Save stevebartholomew/1639128 to your computer and use it in GitHub Desktop.
time a block of ruby code
# Example:
# rendered_content = t("rendering layout") do
# layout.render('item' => self, 'contents' => contents)
# end
#
def t(title, &block)
puts "==========="
puts title
beginning_time = Time.now
result = yield
end_time = Time.now
puts "Time elapsed #{(end_time - beginning_time)*1000} millisecond"
puts "=========="
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment