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.
I know about KCachegrind for Linux, but I would prefer something that I can run on Windows/Mac without installing KDE.
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With