daneads / pycallgraph2

pycallgraph2 is a maintained fork of pycallgraph, a Python module that creates call graphs for Python programs.
GNU General Public License v2.0
219 stars 34 forks source link

meaning of different colored boxes #13

Open vainaixr opened 5 years ago

vainaixr commented 5 years ago

what is the meaning of different colored boxes, and what is the difference between them?

daneads commented 5 years ago

The colored boxes are a rough indication of both the time spent on the method, and the number of times that method was called. The script uses a formula to calculate a (hue, saturation, value) code that is transformed to rgb.

Broadly, the scale goes from gray/light blue -> purple -> pink based on how much time that method took as a fraction of the entire time.

You can see this calculation in the output.py code:

    def node_color(self, node):
        value = float(node.time.fraction * 2 + node.calls.fraction) / 3
        return Color.hsv(value / 2 + .5, value, 0.9)

    def edge_color(self, edge):
        value = float(edge.time.fraction * 2 + edge.calls.fraction) / 3
        return Color.hsv(value / 2 + .5, value, 0.7)