Class: HeapProfiler::Analyzer::ShapeEdgeDimension
- Inherits:
-
Object
- Object
- HeapProfiler::Analyzer::ShapeEdgeDimension
- Defined in:
- lib/heap_profiler/analyzer.rb
Instance Method Summary collapse
-
#initialize ⇒ ShapeEdgeDimension
constructor
A new instance of ShapeEdgeDimension.
- #process(_index, object) ⇒ Object
- #top_n(max) ⇒ Object
Constructor Details
#initialize ⇒ ShapeEdgeDimension
Returns a new instance of ShapeEdgeDimension.
183 184 185 |
# File 'lib/heap_profiler/analyzer.rb', line 183 def initialize @stats = Hash.new(0) end |
Instance Method Details
#process(_index, object) ⇒ Object
187 188 189 190 191 |
# File 'lib/heap_profiler/analyzer.rb', line 187 def process(_index, object) if name = object[:edge_name] @stats[name] += 1 end end |
#top_n(max) ⇒ Object
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/heap_profiler/analyzer.rb', line 193 def top_n(max) @stats.sort do |(a_name, a_count), (b_name, b_count)| cmp = b_count <=> a_count if cmp == 0 a_name <=> b_name else cmp end end.take(max) end |