-
Notifications
You must be signed in to change notification settings - Fork 7
perf: profile and speed up unit tests #251
Description
Overview
Some unit tests run slow. This task profiles the PyAutoArray test suite to identify the slowest tests, diagnose bottlenecks, and apply targeted optimizations. The outcome will include a reusable prompt template that can be applied to PyAutoGalaxy and PyAutoLens afterward.
Plan
- Profile the full PyAutoArray test suite to rank all tests by duration
- Identify and categorize the slowest tests by bottleneck type (computation, fixtures, I/O)
- Deep-profile the worst offenders with cProfile to find specific hot functions
- Propose targeted speedups for approval before making changes
- Implement approved optimizations and re-profile to confirm improvement
- Produce a reusable prompt for applying the same process to PyAutoGalaxy and PyAutoLens
Detailed implementation plan
Affected Repositories
- PyAutoArray (primary and only)
Work Classification
Library
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| PyAutoArray | main | untracked files only |
Suggested branch: feature/unit-test-profiling
Implementation Steps
- Run
pytest --durations=0on PyAutoArray to get a ranked list of all test durations - Categorize the slowest tests by directory and bottleneck type
- Profile individual slow tests with cProfile to pinpoint hot functions
- For each slow test, identify root cause: oversized inputs, redundant setup, expensive computation, unnecessary I/O
- Present findings with proposed fixes for user approval
- Implement approved changes, verifying each test still passes
- Re-run full suite to confirm all tests pass and measure overall speedup
- Write a reusable prompt template (with lessons learned) for PyAutoGalaxy and PyAutoLens
Key Files
test_autoarray/conftest.py— 70+ fixturestest_autoarray/inversion/— 36 test files (likely hotspot)test_autoarray/structures/— 26 test filestest_autoarray/profile_tst.py— existing profiling script
Original Prompt
Click to expand starting prompt
This is a generic source code improvement that applies to all five PyAuto repos.
Basically, some unit test run slow, and this dev work aims to profile the unit tests
and speed them up as much as possible. We dont want to change numerical values on unit
tests where possile, hwoever I am also confident currently that the source code is stable
thus for the slower unit tesrts if there are safe changes we can make to speed them up, then we should do so,
but prompt me on the.
To begin, can we run this on PyAutoArray and I'll see how it goes and we
can then run it on the other repos.