Sha256: 273c872e88ecfe9c01a0e12776edc55a6e1cbc02daacbfbaf5a626b551d76870
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
require 'benchmark' module Forcast module Utils module Measure # # 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. def self.bench(title) puts "#{title}... " result = Benchmark.bm do |x| yield(x) end puts "Salida Bench" end def self.measure(title) puts "#{title}... " result = Benchmark.measure do yield end $stderr.printf "%.03fs\n", result.total end # n = 50000 # FORCAST::Benchmark.bench("pagar_servicio") do |x| # x.report { for i in 1..n; a = "1"; end } # x.report { n.times do ; a = "1"; end } # x.report { 1.upto(n) do ; a = "1"; end } # end # FORCAST::Benchmark.measure("pagar_servicio") do # "a"*1_000_000 # end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
forcast-0.0.110 | lib/forcast/utils/measure.rb |