Class: HeapProfiler::AbstractResults
- Inherits:
-
Object
- Object
- HeapProfiler::AbstractResults
- Defined in:
- lib/heap_profiler/results.rb
Direct Known Subclasses
Constant Summary collapse
- UNIT_PREFIXES =
{ 0 => 'B', 3 => 'kB', 6 => 'MB', 9 => 'GB', 12 => 'TB', 15 => 'PB', 18 => 'EB', 21 => 'ZB', 24 => 'YB', }.freeze
- METRICS =
["memory", "objects", "strings", "shape_edges"].freeze
- GROUPED_METRICS =
["memory", "objects"]
- GROUPINGS =
["gem", "file", "location", "class"].freeze
Class Attribute Summary collapse
-
.top_entries_count ⇒ Object
Returns the value of attribute top_entries_count.
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize ⇒ AbstractResults
constructor
A new instance of AbstractResults.
- #normalize_path(path) ⇒ Object
- #print_output(io, topic, detail) ⇒ Object
- #print_output2(io, topic1, topic2, detail) ⇒ Object
- #print_title(io, title) ⇒ Object
- #scale_bytes(bytes) ⇒ Object
Constructor Details
#initialize ⇒ AbstractResults
Returns a new instance of AbstractResults.
28 29 30 |
# File 'lib/heap_profiler/results.rb', line 28 def initialize(*, **) raise NotImplementedError end |
Class Attribute Details
.top_entries_count ⇒ Object
Returns the value of attribute top_entries_count.
25 26 27 |
# File 'lib/heap_profiler/results.rb', line 25 def top_entries_count @top_entries_count end |
Instance Attribute Details
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
21 22 23 |
# File 'lib/heap_profiler/results.rb', line 21 def dimensions @dimensions end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
21 22 23 |
# File 'lib/heap_profiler/results.rb', line 21 def types @types end |
Instance Method Details
#normalize_path(path) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/heap_profiler/results.rb', line 46 def normalize_path(path) @normalize_path ||= {} @normalize_path[path] ||= begin if %r!(/gems/.*)*/gems/(?<gemname>[^/]+)(?<rest>.*)! =~ path "#{gemname}#{rest}" elsif %r!ruby/2\.[^/]+/(?<stdlib>[^/.]+)(?<rest>.*)! =~ path "ruby/lib/#{stdlib}#{rest}" elsif %r!(?<app>[^/]+/(bin|app|lib))(?<rest>.*)! =~ path "#{app}#{rest}" else path end end end |
#print_output(io, topic, detail) ⇒ Object
38 39 40 |
# File 'lib/heap_profiler/results.rb', line 38 def print_output(io, topic, detail) io.puts "#{@colorize.path(topic.to_s.rjust(10))} #{detail}" end |
#print_output2(io, topic1, topic2, detail) ⇒ Object
42 43 44 |
# File 'lib/heap_profiler/results.rb', line 42 def print_output2(io, topic1, topic2, detail) io.puts "#{@colorize.path(topic1.to_s.rjust(10))} #{@colorize.path(topic2.to_s.rjust(6))} #{detail}" end |
#print_title(io, title) ⇒ Object
32 33 34 35 36 |
# File 'lib/heap_profiler/results.rb', line 32 def print_title(io, title) io.puts io.puts title io.puts @colorize.line("-----------------------------------") end |
#scale_bytes(bytes) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/heap_profiler/results.rb', line 61 def scale_bytes(bytes) return "0 B" if bytes.zero? scale = Math.log10(bytes).div(3) * 3 scale = 24 if scale > 24 format("%.2f #{UNIT_PREFIXES[scale]}", (bytes / 10.0**scale)) end |