Skip to content

Instantly share code, notes, and snippets.

@rociiu
Created September 3, 2010 00:24
Show Gist options
  • Save rociiu/563190 to your computer and use it in GitHub Desktop.
Save rociiu/563190 to your computer and use it in GitHub Desktop.
def time_consuming(&block)
raise "Must wrapping a block" unless block_given?
t1 = Time.now
yield
t2 = Time.now
puts "Time consumed: #{t2 - t1 }"
end
def hello
count = 0
(1..1000).each do |i|
count += i
end
puts count
end
time_consuming {
hello
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment