Class: Benchmark::Report
- Inherits:
-
Object
- Object
- Benchmark::Report
- Defined in:
- mrbgems/mruby-benchmark/mrblib/benchmark.rb
Overview
Report class for formatted benchmark output
Instance Method Summary collapse
-
#initialize(width = 0) ⇒ Report
constructor
A new instance of Report.
- #report(label = "") ⇒ Object
- #results ⇒ Object
Constructor Details
#initialize(width = 0) ⇒ Report
Returns a new instance of Report.
41 42 43 44 |
# File 'mrbgems/mruby-benchmark/mrblib/benchmark.rb', line 41 def initialize(width = 0) @width = width @results = [] end |
Instance Method Details
#report(label = "") ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'mrbgems/mruby-benchmark/mrblib/benchmark.rb', line 46 def report(label = "") tms = Benchmark.measure { yield } # Create new Tms with label set tms = Benchmark::Tms.new(tms.utime, tms.stime, tms.cutime, tms.cstime, tms.real, label, tms.objects, tms.memory) label_str = label.to_s if label_str.length < @width label_str = label_str + " " * (@width - label_str.length) end if $stdout $stdout.print label_str $stdout.print tms.to_s end @results << tms tms end |
#results ⇒ Object
66 67 68 |
# File 'mrbgems/mruby-benchmark/mrblib/benchmark.rb', line 66 def results @results end |