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

3

9

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 "

Connatural answered 22/7, 2013 at 17:29 Comment(4)
Have you tried to pip install RunSnakeRun?Virgenvirgie
@Virgenvirgie worked fine for me on win7 :)Broadminded
Alright, I'll try getting pip and doing that.Connatural
There's this method. Not pretty, but it works.Dwell
C
2

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

Connatural answered 22/2, 2015 at 18:7 Comment(0)
C
1

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.

Community answered 25/9, 2015 at 9:52 Comment(0)
R
1

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.

Richma answered 23/11, 2019 at 19:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.