一个python nose插件,使用cprofile而不是默认的hotshot profiler进行分析。
nose-cprof的Python项目详细描述
使用cprofile分析的插件 nosetests,而不是 内置的热射剖面仪。
分析测试有助于在 代码,特别是如果可以创建一个综合测试来关注该区域 令人担忧的。
此插件生成的输出可以使用 pstats_viewer,或任何 其他pstats兼容的查看器。
开始
先决条件
这是nose的插件, 所以没有安装它是没用的。
安装
pip install nose-cprof
使用量
此插件向nosetests:
添加了一些新选项--with-cprofile Enable plugin cProfiler: Use this plugin to run tests using the cProfile profiler. [NOSE_WITH_CPROFILE] --cprofile-stats-file=FILE Output file name; default "stats.dat" --cprofile-stats-erase Erase previously-collected profiling statistics before run. Without this option, new profiling stats will be merged with the prior contents of the output file.