Skip to content
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

perf: improve performance of Baker.get_fields() #452

Merged
merged 2 commits into from
Oct 14, 2023
Merged

perf: improve performance of Baker.get_fields() #452

merged 2 commits into from
Oct 14, 2023

Conversation

joekohlsdorf
Copy link
Contributor

Describe the change
#352 was meant to be a cosmetic change which introduced a performance regression.

This PR reduces the time complexity of get_fields() from O(n*m) to O(n).

I have a project of significant size (over 50k tests), this change reduces the total runtime of the test suite by ~200% back to what we saw before release 1.8.0.
I also tried other approaches, for example using filter or turning this into a cached property but these didn't achieve a better result.

PR Checklist

joekohlsdorf and others added 2 commits October 13, 2023 11:45
PR#352 was meant to be a cosmetic change which introduced a severe performance regression.
This change reduces time complexity from O(n*m) to O(n).
@amureki
Copy link
Collaborator

amureki commented Oct 14, 2023

@joekohlsdorf hey Joe, this is a fantastic suggestion! Many thanks for reporting the issue, finding the regression and fixing it altogether! 🥇
Happy to hear that model-bakery serves your project with ~50k tests, this is a good note to me to care about the performance here.

I am merging this and issuing a new release right away.

@amureki amureki merged commit 189c2bf into model-bakers:main Oct 14, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants