Module: Era
- Defined in:
- lib/era.rb,
lib/era/version.rb
Constant Summary collapse
- VERSION =
'0.0.3'
Class Method Summary collapse
-
.time(this_many = 1) ⇒ Object
Evaluates a block and prints the time it took.
Class Method Details
.time(this_many = 1) ⇒ Object
Evaluates a block and prints the time it took. Returns the block value. Takes an optional argument for number of times to run the block.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/era.rb', line 9 def self.time this_many = 1 value = nil s = Benchmark.realtime do this_many.pred.times do yield end value = yield end puts "Elapsed time: #{s * 1000} ms" value end |