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

后端 未结 2 1672
孤街浪徒
孤街浪徒 2021-02-03 22:18

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

2条回答
  •  渐次进展
    2021-02-03 23:00

    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)

提交回复
热议问题