pytest-plugins icon indicating copy to clipboard operation
pytest-plugins copied to clipboard

pytest-profiling: option to include setup/teardown into the output

Open dimaqq opened this issue 5 years ago • 7 comments

pytest-profiling outputs profiles of individual tests and a combined profile of all tests

It seems that setup/teardown is not included in the profile.

I wish there was an option to profile everything, including setup, teardown and fixtures...

dimaqq avatar Mar 06 '19 08:03 dimaqq

Hi there - we just merged #94 which should fix this issue - we'll get a release out very soon, thanks!

eeaston avatar Mar 20 '19 18:03 eeaston

Thanks!

I've built from source (tricky!) and as far as I can tell, I can indeed see setup and teardown costs.

Perhaps due to other plugins or project complexity or just the nature of asyncio the resulting profile is less useful / harder to understand than that made by pytest-profiling==1.6.0:

Screenshot 2019-03-26 at 13 31 27

The dominant part is just pytest calling pytest and getting back to pytest (via asyncio?).

I reckon that's a subject for another ticket/pr/whatever...

dimaqq avatar Mar 26 '19 04:03 dimaqq

Hi, There is any option to make this fix configurable. I have a situation which i want to profile just the test, without the fixture code itself.

More details: I'm using pypy, so a normal profiling wont be good, pypy requires warmup to detect the hot spots on the code and jit them. I'm using pytest-profiling and pytest-benchmark together, the benchmark plugin have a warmup option and i'm looking for something similar here.

I can implement this on my code (the warmup/setup section) but i need an option to not profile all the pytest code which my test cause to run, and profile just the test itself.

Thank you.

kosh-b avatar Oct 21 '19 20:10 kosh-b

Hi, There is any option to make this fix configurable.

I would be happy to give it a try! Do you have any recommandations @eeaston before I deep dive into the code :male_detective: ?

benjaminrigaud avatar Dec 03 '19 09:12 benjaminrigaud

@benjaminrigaud Hi there (sorry for the super slow reply!!) The way I'd do this is implement both new and old version of the fix in #94 - as well as add a cmdline switch to control which version to use. So if say --no-profile-fixtures is passed in, then the code in pytest_runtest_protocol is a no-op.

eeaston avatar Nov 19 '21 16:11 eeaston

I would also be interested in having an option to de/activate fixture time in the profiling!

Is there already something like that available?

Zaubeerer avatar Jun 24 '22 14:06 Zaubeerer

Could the help wanted label be slapped on this issue?

And, perhaps, if maintainers consider that reasonable, good first issue?

dimaqq avatar Dec 15 '22 00:12 dimaqq