Module: VisualCallGraph
Instance Method Summary collapse
Instance Method Details
#trace(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/visual_call_graph.rb', line 7 def trace( = {}) graph = GraphManager.new() trace = TracePoint.new(:call, :return) do |event| case event.event when :return then graph.pop when :call then graph.add_edges(event) end end trace.enable yield trace.disable graph.output(png: "#{Dir.pwd}/call_graph.png") puts "Call graph created with a total of #{graph.node_count} #{graph.node_count > 1 ? 'nodes' : 'node'}." end |