public Method

Benchmark.measure(label = "") { || ... }

Returns the time used to execute the given block as a Benchmark::Tms object.

Source Code

# File benchmark.rb, line 291
def measure(label = "") # :yield:
  t0, r0 = Benchmark.times, Time.now
  yield
  t1, r1 = Benchmark.times, Time.now
  Benchmark::Tms.new(t1.utime  - t0.utime, 
                     t1.stime  - t0.stime, 
                     t1.cutime - t0.cutime, 
                     t1.cstime - t0.cstime, 
                     r1.to_f - r0.to_f,
                     label)
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.