本文主要是介绍(挖坑) Python调用图工具,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
基本效果
输入
#!/usr/bin/env python
'''
This example demonstrates a simple use of pycallgraph.
'''
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutputclass Banana:def eat(self):passclass Person:def __init__(self):self.no_bananas()def no_bananas(self):self.bananas = []def add_banana(self, banana):self.bananas.append(banana)def eat_bananas(self):[banana.eat() for banana in self.bananas]self.no_bananas()def main():graphviz = GraphvizOutput()graphviz.output_file = 'basic.png'with PyCallGraph(output=graphviz):person = Person()for a in xrange(10):person.add_banana(Banana())person.eat_bananas()if __name__ == '__main__':main()
输出
官方文档
Python Call Graph
这篇关于(挖坑) Python调用图工具的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!