nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 396 forks source link

see time taken on each individual test #532

Open tansaku opened 12 years ago

tansaku commented 12 years ago

It would be great to be able to see the time taken for each individual test rather than just for the entire test suite. I'm running with sniffer and sometimes one test takes a long time to run, and tracking that down currently seems to involve removing sets of tests at random to see whether the overall running time is reduced. A simple output of time for each test would really help.

Is this something I can achieve in existing config? I searched issues for "performance", "profiling" and "time" and didn't seem to find a similar issue, so opened this new one.

Many thanks in advance

erikrose commented 12 years ago

Actually, if you pass --with-xunit, you'll get exactly what you want, though it will have a bunch of XML around it.

tansaku commented 12 years ago

Hi Erik, many thanks! That's extremely helpful.

<?xml version="1.0" encoding="UTF-8"?>

Although the individual times didn't add up to the overall test time I'm getting:

localhost:faq samueljoseph$ nosetests

.............

Ran 13 tests in 3.365s

but it allowed me to work out that the problem was down to an import of a particular linguistics library, since that happens outside of the actual tests.

Thanks again!

erikrose commented 12 years ago

Glad I could help! I'm not sure offhand where the extra time comes in, but my guess would be setup and teardown time.

tansaku commented 12 years ago

yes, I guessed the setup, but actually it was the import statements. As I'm sure you know the import statements run code in any module that gets pulled in, and one module was doing a big file load. Took a while to find it :-)