Question

I want to profile python code on Widnows 7. I would like to use something a little more user friendly than the raw dump of cProfile. In that search I found the GUI RunSnakeRun, but I cannot find a way to download RunSnakeRun on Windows. Is it possible to use RunSnakeRun on windows or what other tools could I use?

Edit: I have installed RunSnakeRun now. That's progress, thanks guys. How do you run it without a linux command line?

Edit 2: I am using this tutorial http://sullivanmatas.wordpress.com/2013/02/03/profiling-python-scripts-with-runsnakerun/ but I hang up at the last line with "python: can't open file 'runsnake.py': [Errno 2] No such file or directory "

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top