Class: BenchmarkX::Report
- Inherits:
-
Benchmark::Report
- Object
- Benchmark::Report
- BenchmarkX::Report
- Defined in:
- lib/benchmarkx.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#gruff ⇒ Object
readonly
Returns the value of attribute gruff.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#reals ⇒ Object
readonly
Returns the value of attribute reals.
-
#stimes ⇒ Object
readonly
Returns the value of attribute stimes.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
-
#utimes ⇒ Object
readonly
Returns the value of attribute utimes.
Instance Method Summary collapse
-
#initialize(width = 0, fmtstr = nil) ⇒ Report
constructor
A new instance of Report.
- #initialize_orig ⇒ Object
- #item(label = "", *fmt, &blk) ⇒ Object (also: #report)
- #record(label, time) ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(width = 0, fmtstr = nil) ⇒ Report
Returns a new instance of Report.
107 108 109 110 111 112 113 114 |
# File 'lib/benchmarkx.rb', line 107 def initialize(width = 0, fmtstr = nil) initialize_orig(width, fmtstr) @gruff = Gruff::SideBar.new @gruff.x_axis_label = "sec" @gruff.sort = false @labels, @utimes, @stimes, @totals, @reals = [], [], [], [], [] @filename = "graph.png" end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
102 103 104 |
# File 'lib/benchmarkx.rb', line 102 def filename @filename end |
#gruff ⇒ Object (readonly)
Returns the value of attribute gruff.
103 104 105 |
# File 'lib/benchmarkx.rb', line 103 def gruff @gruff end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
103 104 105 |
# File 'lib/benchmarkx.rb', line 103 def labels @labels end |
#reals ⇒ Object (readonly)
Returns the value of attribute reals.
103 104 105 |
# File 'lib/benchmarkx.rb', line 103 def reals @reals end |
#stimes ⇒ Object (readonly)
Returns the value of attribute stimes.
103 104 105 |
# File 'lib/benchmarkx.rb', line 103 def stimes @stimes end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals.
103 104 105 |
# File 'lib/benchmarkx.rb', line 103 def totals @totals end |
#utimes ⇒ Object (readonly)
Returns the value of attribute utimes.
103 104 105 |
# File 'lib/benchmarkx.rb', line 103 def utimes @utimes end |
Instance Method Details
#initialize_orig ⇒ Object
105 |
# File 'lib/benchmarkx.rb', line 105 alias :initialize_orig :initialize |
#item(label = "", *fmt, &blk) ⇒ Object Also known as: report
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/benchmarkx.rb', line 116 def item(label = "", *fmt, &blk) # copied from benchmark.rb print label.ljust(@width) res = Benchmark::measure(&blk) print res.format(@fmtstr, *fmt) # new record(label, res) # copied from benchmark.rb res end |
#record(label, time) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/benchmarkx.rb', line 131 def record(label,time) @labels << label @utimes << time.utime @stimes << time.stime @totals << time.total @reals << time.real end |
#render ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'lib/benchmarkx.rb', line 139 def render @labels.each_with_index{|label, idx| @gruff.labels[idx] = label } @gruff.data("user", @utimes) @gruff.data("system", @stimes) @gruff.data("total", @totals) @gruff.data("real", @reals) @gruff.write(@filename) return self end |