Class: Memory::Report
- Inherits:
-
Object
- Object
- Memory::Report
- Defined in:
- lib/memory/report.rb
Instance Attribute Summary collapse
-
#aggregates ⇒ Object
readonly
Returns the value of attribute aggregates.
-
#total_allocated ⇒ Object
readonly
Returns the value of attribute total_allocated.
-
#total_retained ⇒ Object
readonly
Returns the value of attribute total_retained.
Class Method Summary collapse
Instance Method Summary collapse
-
#add(sampler) ⇒ Object
Add all samples from the given sampler to this report.
- #as_json ⇒ Object
-
#concat(allocations) ⇒ Object
Add allocations to this report.
-
#initialize(aggregates) ⇒ Report
constructor
A new instance of Report.
- #print(io = $stderr) ⇒ Object
- #to_json ⇒ Object
Constructor Details
Instance Attribute Details
#aggregates ⇒ Object (readonly)
Returns the value of attribute aggregates.
30 31 32 |
# File 'lib/memory/report.rb', line 30 def aggregates @aggregates end |
#total_allocated ⇒ Object (readonly)
Returns the value of attribute total_allocated.
28 29 30 |
# File 'lib/memory/report.rb', line 28 def total_allocated @total_allocated end |
#total_retained ⇒ Object (readonly)
Returns the value of attribute total_retained.
29 30 31 |
# File 'lib/memory/report.rb', line 29 def total_retained @total_retained end |
Class Method Details
.general ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/memory/report.rb', line 10 def self.general Report.new([ Aggregate.new("By Gem", &:gem), Aggregate.new("By File", &:file), Aggregate.new("By Location", &:location), Aggregate.new("By Class", &:class_name), ValueAggregate.new("Strings By Gem", &:gem), ValueAggregate.new("Strings By Location", &:location), ]) end |
Instance Method Details
#add(sampler) ⇒ Object
Add all samples from the given sampler to this report.
33 34 35 |
# File 'lib/memory/report.rb', line 33 def add(sampler) self.concat(sampler.allocated) end |
#as_json ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/memory/report.rb', line 61 def as_json { total_allocated: @total_allocated.as_json, total_retained: @total_retained.as_json, aggregates: @aggregates.map(&:as_json) } end |
#concat(allocations) ⇒ Object
Add allocations to this report.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/memory/report.rb', line 38 def concat(allocations) allocations.each do |allocation| @total_allocated << allocation @total_retained << allocation if allocation.retained @aggregates.each do |aggregate| aggregate << allocation end end end |
#print(io = $stderr) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/memory/report.rb', line 49 def print(io = $stderr) io.puts "\# Memory Profile", nil io.puts "- Total Allocated: #{@total_allocated}" io.puts "- Total Retained: #{@total_retained}" io.puts @aggregates.each do |aggregate| aggregate.print(io) end end |
#to_json ⇒ Object
69 70 71 |
# File 'lib/memory/report.rb', line 69 def to_json(...) as_json.to_json(...) end |