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 "

4

3 回答 3

2

标准解决方案是使用 cProfile(在标准库中),然后在 RunSnakeRun 中打开配置文件: http ://www.vrplumber.com/programming/runsnakerun/

cProfile,但是仅在每个功能级别进行配置文件。如果您想要逐行分析,请尝试行分析器: https ://github.com/rkern/line_profiler

于 2015-02-22T18:07:50.217 回答
1

还有py-spy,用 Rust 编写,即使在生产环境中也可以安全使用,无需修改任何代码。

在 Windows 上工作,安装 run pip install py-spy

从那里你可以运行py-spy record -o profile.svg -- python myprogram.py它产生漂亮的火焰图。

于 2019-11-23T19:22:38.593 回答
1

我按照这些安装说明安装了 runnake 。

该步骤python runsnake.py profile.pfl失败,因为安装步骤 ( easy_install SquareMap RunSnakeRun) 没有创建文件runsnake.py

对我来说(在 Ubuntu 上),安装步骤在/usr/local/bin/runsnake. 我通过阅读安装步骤的控制台输出来解决这个问题。它可能在 Windows 上的不同位置,但它应该打印在easy_install. 要读取配置文件,我可以执行/usr/local/bin/runsnake profile.pfl.

于 2015-09-25T09:52:00.647 回答