Class: Memtf::Reporter
- Inherits:
-
Object
- Object
- Memtf::Reporter
- Defined in:
- lib/memtf/reporter.rb
Overview
Encapsulates the formatting and output of Memtf analysis.
Example Report:
+-----------------------------+--------+---------+---------+---------+---------+
| Class | Impact | Leakage | Change | Objects | Change |
+-----------------------------+--------+---------+---------+---------+---------+
| Array | 96.85% | 4.972MB | 4.972MB | 2189 | 1985 |
...
Constant Summary collapse
- HEADERS =
The report table headers
['Class', 'Impact', 'Leakage', 'Change', 'Objects', 'Change']
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.report(group) ⇒ Object
Print the analysis in a concise tabular format.
Instance Method Summary collapse
-
#initialize(group, options = {}) ⇒ Reporter
constructor
A new instance of Reporter.
-
#report ⇒ Terminal::Table
Print the analysis in a concise tabular format.
Constructor Details
#initialize(group, options = {}) ⇒ Reporter
Returns a new instance of Reporter.
26 27 28 29 |
# File 'lib/memtf/reporter.rb', line 26 def initialize(group, ={}) @group = group @options = end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
17 18 19 |
# File 'lib/memtf/reporter.rb', line 17 def group @group end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/memtf/reporter.rb', line 17 def @options end |
Class Method Details
.report(group) ⇒ Object
Print the analysis in a concise tabular format.
22 23 24 |
# File 'lib/memtf/reporter.rb', line 22 def self.report(group) new(group).report end |
Instance Method Details
#report ⇒ Terminal::Table
Print the analysis in a concise tabular format.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/memtf/reporter.rb', line 34 def report Terminal::Table.new(:headings => HEADERS) do |t| group_analysis = Memtf::Analyzer.analyze_group(group) group_analysis.sort_by { |k,v| -v['impact'] }.each do |k,v| t << [k, to_pct(v['impact']), to_MB(v['size']), to_MB(v['size_delta']), v['count'], v['count_delta']] end end end |