How do I measure the execution time of python unit tests with nosetests?

99封情书 提交于 2019-12-09 04:21:15

问题


Is there a way to time the execution time of individual Python tests which are run by nosetests ?


回答1:


You might try the nose plug-in posted here: https://github.com/mahmoudimus/nose-timer (or available via pip / PyPi). You can also use the built-in plugin --with-profile to do more serious profiling.




回答2:


Alternatively:

python -m cProfile -o profile.out `which nosetests` .

The output from can be viewed using, for example, runsnakerun, which makes it visually very obvious where your performance problems are. (e.g. it might be in a common method that many tests indirectly call)



来源:https://stackoverflow.com/questions/5481282/how-do-i-measure-the-execution-time-of-python-unit-tests-with-nosetests

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!