Module: Forcast::Utils::Measure
- Defined in:
- lib/forcast/utils/measure.rb
Class Method Summary collapse
-
.bench(title) ⇒ Object
Measure execution of block and display result.
- .measure(title) ⇒ Object
Class Method Details
.bench(title) ⇒ Object
Measure execution of block and display result
Time is measured by Benchmark module, displayed time is total (user cpu time + system cpu time + user and system cpu time of children) This is not wallclock time.
12 13 14 15 16 17 18 |
# File 'lib/forcast/utils/measure.rb', line 12 def self.bench(title) puts "#{title}... " result = Benchmark.bm do |x| yield(x) end puts "Salida Bench" end |
.measure(title) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/forcast/utils/measure.rb', line 19 def self.measure(title) puts "#{title}... " result = Benchmark.measure do yield end $stderr.printf "%.03fs\n", result.total end |