Module: Benchmark
- Defined in:
- lib/benchmark/timed_each.rb
Class Method Summary (collapse)
-
+ (Object) timed_each(collection, options = {}, &block)
Iterate over the passed in collection, outputing benchmark info at each step.
Class Method Details
+ (Object) timed_each(collection, options = {}, &block)
Iterate over the passed in collection, outputing benchmark info at each step
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/benchmark/timed_each.rb', line 13 def self.timed_each(collection, ={}, &block) caption = [:start_caption] || "Started processing collection\n" finish_caption = [:finish_caption] || "Finished processing collection" label_width = nil fmtstr = [:format] || "- %r\n" item_to_s = [:item_to_s] || :to_s benchmark(caption, label_width, fmtstr, finish_caption) do |x| [collection.map do |item| x.report(" processing #{item.send(item_to_s)} -") do block.call(*item) end end.inject(&:+)] end end |