Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call-graph profilers in Python

In my python program i have used a lot of modules and am trying to have a count of the functions called and the call chains involved. Is there a tool/module in python which will provide me with these statistics.

like image 979
Rahul Avatar asked Nov 03 '10 06:11

Rahul


2 Answers

I've used this. It didn't work for my purposes since my app has many threads running at once and and I ended up with 12000 links and graphviz couldn't compile it. But it worked when I ran it on a single thread.

http://pycallgraph.slowchop.com/

like image 70
Falmarri Avatar answered Nov 06 '22 21:11

Falmarri


pydoc -k profile

will give you a list of what's on your system. I've used profile and cProfile.

It's as easy as:


if __name__ == '__main__':
 if PROFILING:
  import cProfile
  cProfile.run("main()")
 else:
  main()
like image 3
jcomeau_ictx Avatar answered Nov 06 '22 21:11

jcomeau_ictx