Reputation: 15605
I have looked at --with-timer
and --with-profile
to profile my tests but these options either give too little info or too much info.
Example, if I have the following test:
def test_foo():
do_something()
do_something_else()
I just want to profile how long each function call or each line within the test took. So the output will be something like:
do_something() : .5 seconds
do_something_else() : .5 seconds
test_foo() : 1 seconds
Upvotes: 2
Views: 332
Reputation: 10353
Inspired by this talk, you could user the Xunit plugin and post-process its xml
Use --with-xunit and the following code to process nosetests.xml
from xml.etree.cElementTree import parse
from operator import itemgetter
elems = parse(open("nosetests.xml")).getiterator("testcase")
tests = sorted(((e.get("name"), int(e.get("time"))) for e in elems),
key=itemgetter(1), reverse=1)
for test in (test for test in tests if test[1]):
print "%s: %s sec" % test
Upvotes: 1