简体   繁体   中英

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

有没有办法计算由nosetests运行的单个Python测试的执行时间?

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.

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. (eg it might be in a common method that many tests indirectly call)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM