Class: AppMap::Algorithm::Stats::Result
- Inherits:
-
Struct
- Object
- Struct
- AppMap::Algorithm::Stats::Result
- Defined in:
- lib/appmap/algorithm/stats.rb
Instance Attribute Summary collapse
-
#class_frequency ⇒ Object
Returns the value of attribute class_frequency.
-
#method_frequency ⇒ Object
Returns the value of attribute method_frequency.
Instance Method Summary collapse
Instance Attribute Details
#class_frequency ⇒ Object
Returns the value of attribute class_frequency
9 10 11 |
# File 'lib/appmap/algorithm/stats.rb', line 9 def class_frequency @class_frequency end |
#method_frequency ⇒ Object
Returns the value of attribute method_frequency
9 10 11 |
# File 'lib/appmap/algorithm/stats.rb', line 9 def method_frequency @method_frequency end |
Instance Method Details
#as_text ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/appmap/algorithm/stats.rb', line 47 def as_text lines = [ "Class frequency:", "----------------", ] + class_frequency.map(&:to_a).map(&:reverse).map { |line | line.join("\t") } + [ "", "Method frequency:", "----------------", ] + method_frequency.map(&:to_a).map(&:reverse).map { |line | line.join("\t") } lines.join("\n") end |
#limit!(limit) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/appmap/algorithm/stats.rb', line 40 def limit!(limit) self.class_frequency = class_frequency[0...limit] self.method_frequency = method_frequency[0...limit] self end |
#merge!(other) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/appmap/algorithm/stats.rb', line 10 def merge!(other) merge = lambda do |freq, other_freq| freq_by_name = freq.inject({}) do |table, entry| table.tap do table[entry.name] = entry end end other_freq.each do |other_entry| entry = freq_by_name[other_entry.name] if entry entry.count += other_entry.count else freq << other_entry end end end merge.call(class_frequency, other.class_frequency) merge.call(method_frequency, other.method_frequency) self end |
#sort! ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/appmap/algorithm/stats.rb', line 32 def sort! comparator = ->(a,b) { b.count <=> a.count } class_frequency.sort!(&comparator) method_frequency.sort!(&comparator) self end |