Skip to content

Add configuration options to duration extension #13469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

user27182
Copy link

@user27182 user27182 commented Apr 6, 2025

Purpose

The duration extension is great but is not configurable. It currently only shows 5 slowest durations and only
prints to the console.

This PR adds configuration options:

  1. duration_n_slowest to print any number of durations to console (not just 5)
  2. duration_print_slowest to enable/disable printing to console altogether
  3. duration_write_json to write all durations to a JSON file
  4. duration_print_total to print the total read time to console
  5. duration_limit to emit a warning for long durations above the limit

No tests are yet included. I am a first time contributor and not familiar with dev tools and conventions here... I may need some extra help.

@user27182 user27182 marked this pull request as draft April 6, 2025 00:56
@user27182 user27182 marked this pull request as ready for review April 6, 2025 02:12
@user27182
Copy link
Author

This is ready but I don't think I have the tests configured properly. When I run each test individually locally they each pass on their own. But running the whole suite causes some to fail. Is there some kind of interaction between tests?

@user27182 user27182 changed the title Extend duration extension with configuration options Add configuration options to duration extension Apr 6, 2025
@AA-Turner AA-Turner added the type:proposal a feature suggestion label Apr 9, 2025
@AA-Turner
Copy link
Member

Please add yourself to AUTHORS too. I think it's better to add each option as a new top-level option rather than as a dictionary.

@user27182 user27182 marked this pull request as draft April 10, 2025 20:44
@user27182
Copy link
Author

user27182 commented Apr 10, 2025

I'm going to modify the API a bit to better match pytest. pytest uses --durations=0 to show all durations, whereas this extention currently uses n_slowest=-1 to do the same, so will rename n_slowest to durations and change -1 to 0.
Will rework the console formatting too to match pytest.

@user27182 user27182 marked this pull request as ready for review April 11, 2025 01:47
@user27182
Copy link
Author

I've also added a new option to limit the duration to some value. Should be ready now.

CI is green except there are seemingly unrelated autodoc Python 3.14 errors...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:proposal a feature suggestion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants