Class: Benchmark::Report
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
- 
  
    
      #list  ⇒ 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 +label+ and measured time for the block, formatted by +format+. 
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.
| 359 360 361 | # File 'opal/stdlib/benchmark.rb', line 359 def initialize(width = 0, format = nil) @width, @format, @list = width, format, [] end | 
Instance Attribute Details
#list ⇒ Object (readonly)
An array of Benchmark::Tms objects representing each item.
| 378 379 380 | # File 'opal/stdlib/benchmark.rb', line 378 def list @list 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.
| 368 369 370 371 372 373 | # File 'opal/stdlib/benchmark.rb', line 368 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 |