Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a visual profiler for Python? [closed]

I use cProfile now but I find it tedious to write pstats code just to query the statistics data.

I'm looking for a visual tool that shows me what my Python code is doing in terms of CPU time and memory allocation.

Some examples from the Java world are visualvm and JProfiler.

  • Does something like this exist?
  • Is there an IDE that does this?
  • Would dtrace help?

I know about KCachegrind for Linux, but I would prefer something that I can run on Windows/Mac without installing KDE.

like image 257
Frederik Avatar asked Jul 31 '10 16:07

Frederik


People also ask

What is Vprof?

vprof is a Python package providing rich and interactive visualizations for various Python program characteristics such as running time and memory usage. It supports Python 3.4+ and distributed under BSD license.

What is cProfile Python?

Python cProfile is a set of numbers that shows how long and often program parts are called and run. You can easily format the report as a pstats module. Coding using cProfile is relatively easy. You just need to import the right function and module to call the run function.

What is SnakeViz?

SnakeViz is a browser based graphical viewer for the output of Python's cProfile module and an alternative to using the standard library pstats module. It was originally inspired by RunSnakeRun. SnakeViz works on Python 2.7 and Python 3.

How do you run a memory profiling in Python?

The easiest way to profile a single method or function is the open source memory-profiler package. It's similar to line_profiler , which I've written about before . You can use it by putting the @profile decorator around any function or method and running python -m memory_profiler myscript.


2 Answers

A friend and I have written a Python profile viewer called SnakeViz that runs in a web browser. If you are already successfully using RunSnakeRun SnakeViz may not add that much value, but SnakeViz is much easier to install.

Edit: SnakeViz supports Python 2 and 3 and works on all major systems.

like image 88
jiffyclub Avatar answered Sep 21 '22 13:09

jiffyclub


I'm only aware of RunSnakeRun.

There was also some talk some time ago about an integrated profiler in PyDev (Eclipse), but I don't know if that will ever see the light of day.

Update: Unfortunately it seems that RunSnakeRun is no longer maintained, and it does not support Python 3.

like image 37
nikow Avatar answered Sep 18 '22 13:09

nikow