In: |
benchmark.rb
|
Parent: | Object |
This class is used by the Benchmark.benchmark and Benchmark.bm methods. It is of little direct interest to the user.
Returns an initialized Report instance. Usually, one doesn’t call this method directly, as new Report objects are created by the benchmark and bm methods. width and fmtstr are the label offset and format string used by Tms#format.
# File benchmark.rb, line 401 def initialize(width = 0, fmtstr = nil) @width, @fmtstr = width, fmtstr end
Prints the label and measured time for the block, formatted by fmt. See Tms#format for the formatting rules.
# File benchmark.rb, line 410 def item(label = "", *fmt, &blk) # :yield: print label.ljust(@width) res = Benchmark::measure(&blk) print res.format(@fmtstr, *fmt) res end