123456789_123456789_123456789_123456789_123456789_

Class: Benchmark::Report

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/benchmark.rb

Overview

This class is used by the benchmark and bm methods. It is of little direct interest to the user.

Class Method Summary

Instance Attribute Summary

  • #list readonly

    An array of Tms objects representing each item.

Instance Method Summary

Constructor Details

.new(width = 0, format = nil) ⇒ Report

Returns an initialized Report instance. Usually, one doesn’t call this method directly, as new Report objects are created by the Benchmark#benchmark and Benchmark#bm methods. width and format are the label offset and format string used by Tms#format.

[ GitHub ]

  
# File 'lib/benchmark.rb', line 369

def initialize(width = 0, format = nil)
  @width, @format, @list = width, format, []
end

Instance Attribute Details

#list (readonly)

An array of Tms objects representing each item.

[ GitHub ]

  
# File 'lib/benchmark.rb', line 388

attr_reader :list

Instance Method Details

#item(label = "", *format, &blk) Also known as: #report

Prints the label and measured time for the block, formatted by format. See Tms#format for the formatting rules.

[ GitHub ]

  
# File 'lib/benchmark.rb', line 378

def item(label = "", *format, &blk) # :yield:
  print label.to_s.ljust(@width)
  @list << res = Benchmark.measure(label, &blk)
  print res.format(@format, *format)
  res
end

#report(label = "", *format, &blk)

Alias for #item.

[ GitHub ]

  
# File 'lib/benchmark.rb', line 385

alias report item