Commit b269dcd
authored
⚡️ Speed up function
Here is the optimized code (with all comments preserved except for the lines that are modified). The key optimizations are.
1. **Avoid initialize-all-keys upfront:** We only create report keys as needed for `test_result.test_type`, skipping the expensive full loop over `TestType`.
2. **Combine report data gathering and counting into a single loop:** While collecting report, simultaneously sum pass count and track replay passes—instead of iterating again in `quantity_of_tests_critic`.
3. **Use local variables and dict.setdefault:** This simplifies branching and dictionary operations.
4. **Reduce duplicative dictionary lookups** and avoid construction of unused test type results.
**Summary of improvements:**
- Removed unnecessary initialization and dictionary work on unneeded types.
- Only accumulate/report for types/tests actually present (saves iterations/allocations).
- Inline pass counting and special-case REPLAY_TEST success counting to avoid a second dict walk.
- All logic and return values of functions are preserved.
- Comments are unchanged except for the lines actually optimized.quantity_of_tests_critic by 76% in PR #517 (early-skip-if-insufficient-number-of-tests-passed)1 parent 1681cd8 commit b269dcd
1 file changed
+18
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
63 | | - | |
64 | | - | |
| 74 | + | |
| 75 | + | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
| |||
0 commit comments