Class: Necropsy::LoadGraph
- Inherits:
-
Object
- Object
- Necropsy::LoadGraph
- Defined in:
- lib/necropsy/load_graph.rb
Constant Summary collapse
- OBSERVATION_LIMIT =
50
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(graph:, project:) ⇒ LoadGraph
constructor
A new instance of LoadGraph.
Constructor Details
#initialize(graph:, project:) ⇒ LoadGraph
Returns a new instance of LoadGraph.
32 33 34 35 36 37 38 |
# File 'lib/necropsy/load_graph.rb', line 32 def initialize(graph:, project:) @graph = graph @project = project @resolved = [] @unresolved = [] @dynamic = [] end |
Class Method Details
.record_unrooted_units(graph:, reachability:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/necropsy/load_graph.rb', line 9 def self.record_unrooted_units(graph:, reachability:) reached = (reachability.runtime_alive + reachability.external_alive).to_set root_calls = graph.call_sites.group_by(&:caller_id) units = graph.nodes.values.filter_map do |node| next unless node.kind == :block_entry && !node.test next if reached.include?(node.graph_id) calls = root_calls.fetch(node.graph_id, []) next if calls.empty? { 'definition_id' => node.graph_id, 'file' => node.file, 'top_level_calls' => calls.map(&:message).uniq.sort.first(OBSERVATION_LIMIT) } end.sort_by { |unit| unit.fetch('file') } graph.observation['unrooted_load_units'] = { 'count' => units.length, 'units' => units.first(OBSERVATION_LIMIT), 'truncated' => units.length > OBSERVATION_LIMIT } end |
Instance Method Details
#apply ⇒ Object
40 41 42 43 |
# File 'lib/necropsy/load_graph.rb', line 40 def apply load_sites.each { |site| apply_site(site) } graph.observation['load_graph'] = observation end |