MCPcopy Create free account
hub / github.com/ActiveState/code / graph

Method graph

recipes/Python/578138_gprof2dotpy/recipe-578138.py:2594–2666  ·  view source on GitHub ↗
(self, profile, theme)

Source from the content-addressed store, hash-verified

2592 return name
2593
2594 def graph(self, profile, theme):
2595 self.begin_graph()
2596
2597 fontname = theme.graph_fontname()
2598
2599 self.attr('graph', fontname=fontname, ranksep=0.25, nodesep=0.125)
2600 self.attr('node', fontname=fontname, shape="box", style="filled", fontcolor="white", width=0, height=0)
2601 self.attr('edge', fontname=fontname)
2602
2603 for function in profile.functions.values():
2604 labels = []
2605 if function.process is not None:
2606 labels.append(function.process)
2607 if function.module is not None:
2608 labels.append(function.module)
2609
2610 if self.strip:
2611 function_name = function.stripped_name()
2612 else:
2613 function_name = function.name
2614 if self.wrap:
2615 function_name = self.wrap_function_name(function_name)
2616 labels.append(function_name)
2617
2618 for event in TOTAL_TIME_RATIO, TIME_RATIO:
2619 if event in function.events:
2620 label = event.format(function[event])
2621 labels.append(label)
2622 if function.called is not None:
2623 labels.append("%u\xd7" % (function.called,))
2624
2625 if function.weight is not None:
2626 weight = function.weight
2627 else:
2628 weight = 0.0
2629
2630 label = '\n'.join(labels)
2631 self.node(function.id,
2632 label = label,
2633 color = self.color(theme.node_bgcolor(weight)),
2634 fontcolor = self.color(theme.node_fgcolor(weight)),
2635 fontsize = "%.2f" % theme.node_fontsize(weight),
2636 )
2637
2638 for call in function.calls.values():
2639 callee = profile.functions[call.callee_id]
2640
2641 labels = []
2642 for event in TOTAL_TIME_RATIO, CALLS:
2643 if event in call.events:
2644 label = event.format(call[event])
2645 labels.append(label)
2646
2647 if call.weight is not None:
2648 weight = call.weight
2649 elif callee.weight is not None:
2650 weight = callee.weight
2651 else:

Callers 1

write_graphMethod · 0.95

Calls 15

begin_graphMethod · 0.95
attrMethod · 0.95
wrap_function_nameMethod · 0.95
nodeMethod · 0.95
colorMethod · 0.95
edgeMethod · 0.95
end_graphMethod · 0.95
graph_fontnameMethod · 0.80
stripped_nameMethod · 0.80
node_bgcolorMethod · 0.80
node_fgcolorMethod · 0.80
node_fontsizeMethod · 0.80

Tested by

no test coverage detected