nosetest --with-profile --profile-stats-file输出
runsnake无法读取输出,因为nosetest使用hotshot,如果我想生成一个可以使用runsnake读取的文件,我需要将其转换为:
st = hotshot.stats.load('output')
st.dump_stats( 'output_new')
我可以直接使用cProfile运行测试以使用runsnake进行读取吗?
nosetest --with-profile --profile-stats-file输出
runsnake无法读取输出,因为nosetest使用hotshot,如果我想生成一个可以使用runsnake读取的文件,我需要将其转换为:
st = hotshot.stats.load('output')
st.dump_stats( 'output_new')
我可以直接使用cProfile运行测试以使用runsnake进行读取吗?
根据@squid的答案,您可以使用 鼻子 插件叫 nose-cprof
用cProfile替换鼻子默认探查器,hotshot。
要安装它:
pip install nose-cprof
然后像这样打电话给鼻子:
nosetests --with-cprofile
它应该生成一个cProfile输出文件,然后您可以使用类似的工具进行分析 runsnakerun
。
@ cihanpesend的回答对我来说不太有用(cProfile找不到'nosetests'),但我确实在Linux上取得了成功:
python -m cProfile -o profile.out `which nosetests` .
结果输出在runsnake中正常工作。
(据推测,在Windows上你可以替换它 which nosetests
使用硬编码路径到您的nosetests顶级python脚本。)
一世 认为 你认为nosetests的hotshot profiler的输出与runsnake不兼容是正确的。当然,对于我来说,这两个人并不是一起打得很好。
我没有关于nosetest的信息,除了它是python项目。所以;
python -m cProfile -o outputfile nosetest
然后,
runsnake outputfile
RunSnakeRun对于可视化分析器非常有用。
注意:要运行 runsnake
,你必须安装wx和numpy。
更新:来自omikron的评论; runsnakerun不支持python3配置文件输出。 (我没试过)
或者你可以试试nose-cprof插件:https://github.com/msherry/nose-cprof
它用cProfile取代了hotshot