Class: Benchmark::Job
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/benchmark.rb |
Overview
A Job is a sequence of labelled blocks to be processed by the bmbm method. It is of little direct interest to the user.
Class Method Summary
-
.new(width) ⇒ Job
constructor
Returns an initialized
Job
instance.
Instance Attribute Summary
Instance Method Summary
-
#item(label = "", &blk)
(also: #report)
Registers the given label and block pair in the job list.
-
#report(label = "", &blk)
Alias for #item.
Constructor Details
.new(width) ⇒ Job
Returns an initialized Job
instance. Usually, one doesn’t call this method directly, as new Job
objects are created by the Benchmark#bmbm method. #width is a initial value for the label offset used in formatting; the Benchmark#bmbm method passes its #width argument to this constructor.
Instance Attribute Details
#list (readonly)
An array of 2-element arrays, consisting of label and block pairs.
# File 'lib/benchmark.rb', line 351
attr_reader :list
#width (readonly)
Length of the widest label in the #list.
# File 'lib/benchmark.rb', line 354
attr_reader :width
Instance Method Details
#item(label = "", &blk) Also known as: #report
Registers the given label and block pair in the job list.
# File 'lib/benchmark.rb', line 339
def item(label = "", &blk) # :yield: raise ArgumentError, "no block" unless block_given? label = label.to_s w = label.length @width = w if @width < w @list << [label, blk] self end
#report(label = "", &blk)
Alias for #item.
# File 'lib/benchmark.rb', line 348
alias report item