Speed up pytest execution wall time by ~37%. #383
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before:
644 passed in 19.89s
.After:
644 passed in 12.47s
.Running with
python -m pytest --durations=5
showed this test case was a huge outlier, and timing its execution showed a huge disparity between the timeTechnicalDrawing
thought it took to run and the time its caller saw et up. Dropping the Builder context makes these times lineup.Tested the individual test case speed-up with
hyperfine -- 'python -m pytest tests/test_drafting.py::TestTechnicalDrawing::test_basic_drawing'
which reports before & after of:I dug a little into why it was so much slower under the builder and the answer seems to be ~13k calls to deepcopy, but I haven't dug deeper yet to figure out if there's a way to "transfer" to the builder rather than making copies.
(full disclosure: the next-slowest test case is test_pack.py that I added very recently; I'll be looking into speeding that up next :) )