Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple timing/benchmark mechanism for Ruby
class TimingBenchmark
def measure(label, &block)
@label_times ||= {}
start = Time.now
result = block.call
@label_times[label] = Time.now - start
return result
end
def printout_times
@label_times.each do |label, value|
puts "#{label}: #{value}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment