What tools should I use to profile Python code on window 7 What tools should I use to profile Python code on window 7 windows windows

What tools should I use to profile Python code on window 7


The standard solution is to use cProfile (which is in the standard library) and then open the profiles in RunSnakeRun:http://www.vrplumber.com/programming/runsnakerun/

cProfile, however only profiles at the per-functions level. If you want line by line profiling try line profiler:https://github.com/rkern/line_profiler


I installed runsnake following these installation instructions.

The step python runsnake.py profile.pfl failed because the installation step (easy_install SquareMap RunSnakeRun) did not create a file runsnake.py.

For me (on Ubuntu), the installation step created an executable at /usr/local/bin/runsnake. I figured this out by reading the console output from the installation step. It may be in a different place on Windows, but it should be printed in the output of easy_install. To read a profile file, I can execute /usr/local/bin/runsnake profile.pfl.


There's also py-spy, written in Rust, safe to use even in production, without modifying any code.

Works on Windows, to install run pip install py-spy.

From there you can run py-spy record -o profile.svg -- python myprogram.py which produces nice flame graphs.