man-group / pytest-plugins

A grab-bag of nifty pytest plugins
MIT License
558 stars 82 forks source link

Expose profile/pstats parameters as pytest config variables #81

Open jayvdb opened 6 years ago

jayvdb commented 6 years ago

There are various arguments which are available when calling profile and pstats.

It would be nice to be able to select those via pytest.ini

As percentage or count and regular expression can be in either order, it might be wiser to have that as a single config option. On the command line, the order can be derived from the arg order. Maybe the same can be done by the order in pytest.ini.. ?

ksdme commented 6 years ago

@jayvdb The only configuration option currently triggering/used by this plugin is profile or profile_svg. Do you think sort_stats_by, restrict_stats_by, profiler_timeunit, profiler_subcallsand profiler_builtins are good configuration names?

Maybe the same can be done by the order in pytest.ini.

I do not see why this should not be possible via pytest.ini.

jayvdb commented 6 years ago

All args should mention profile (or maybe profiler), to avoid name clashes with other plugins.

You will find it easier to name things as you develop and run it with various settings.

naught101 commented 3 years ago

Would also be very nice to be able to limit the depth of the graph, and/or exclude functions from system libraries

sivy commented 3 years ago

@jayvdb The only configuration option currently triggering/used by this plugin is profile or profile_svg.

3 years later this seems to still be the case... I had been hoping to override element_number to get more in the test report but I have not been able to figure out how to do that. :(

kronenpj commented 3 years ago

For those still interested in this feature, it was implemented in commit 055bf70fd0fd2e0a06afb014e0ea3da16b2507da. Unfortunately it was never published to pypi.

eeaston commented 2 years ago

Hi, thanks for the good suggestion and sorry for the huge delays! I'll look at adding pytest.ini / setup.cfg / pyproject.toml etc support.

SteveHespelt commented 2 years ago

I looked into commit 055bf70 as mentioned by @kronenpj last July 31. While changing the default print_stats() list length from 20 to some config element_number value is great, some means of exposing the complete set of possible restrictions for the various pstats methods would be ideal. Filtering out (or only including) symbols via the RE restriction would allow one to ignore (or focus on) those profiling results that won't be actionable (ie. I'm not really concerned with the performance of str methods or most standard library classes, functions - it is what is is. Smarter folks than I have worked quite hard to optimize those implementations). I'd rather focus on stuff I've (or project teammates) written & ought to optimize. So using various restrictions would help to do that.

@eeaston - have you done any work on this per your Nov 19, 2021 comment? The above seem like some features that I might work on, might spend more time once the EPL season wraps up? I need to investigate the means other pytest plugins use to grab their config properties from the pytest.ini/setup.cfg/ etc. files. CLI is obvious in the pytest_addoption impl. Good chance for me to learn.