Class: Benchmark::Report
- Inherits:
- 
      Object
      
        - Object
- Benchmark::Report
 
- Defined in:
- lib/benchmark.rb
Overview
This class is used by the Benchmark.benchmark and Benchmark.bm methods. It is of little direct interest to the user.
Instance Attribute Summary collapse
- 
  
    
      #format  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    An array of Benchmark::Tms objects representing each item. 
- 
  
    
      #list  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    An array of Benchmark::Tms objects representing each item. 
- 
  
    
      #width  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    An array of Benchmark::Tms objects representing each item. 
Instance Method Summary collapse
- 
  
    
      #initialize(width = 0, format = nil)  ⇒ Report 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Returns an initialized Report instance. 
- 
  
    
      #item(label = "", *format, &blk)  ⇒ Object 
    
    
      (also: #report)
    
  
  
  
  
  
  
  
  
  
    Prints the labeland measured time for the block, formatted byformat.
Constructor Details
#initialize(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 and #bm methods. width and format are the label offset and format string used by Tms#format.
| 379 380 381 | # File 'lib/benchmark.rb', line 379 def initialize(width = 0, format = nil) @width, @format, @list = width, format, [] end | 
Instance Attribute Details
#format ⇒ Object (readonly)
An array of Benchmark::Tms objects representing each item.
| 398 399 400 | # File 'lib/benchmark.rb', line 398 def format @format end | 
#list ⇒ Object (readonly)
An array of Benchmark::Tms objects representing each item.
| 398 399 400 | # File 'lib/benchmark.rb', line 398 def list @list end | 
#width ⇒ Object (readonly)
An array of Benchmark::Tms objects representing each item.
| 398 399 400 | # File 'lib/benchmark.rb', line 398 def width @width end | 
Instance Method Details
#item(label = "", *format, &blk) ⇒ Object Also known as: report
Prints the label and measured time for the block, formatted by format. See Tms#format for the formatting rules.
| 388 389 390 391 392 393 | # File 'lib/benchmark.rb', line 388 def item(label = "", *format, &blk) # :yield: w = label.to_s.length @width = w if @width < w @list << res = Benchmark.measure(label, &blk) res end |