django-test-profiling
Installation
SKILL.md
Django Test Profiling
Use this skill before changing a Django test suite for speed. Measurement decides which optimization is worth doing; otherwise it is easy to spend time on harmless settings while the real cost sits in startup, database setup, fixture construction, or a small set of slow tests.
Measurement Workflow
-
Capture a full wall-clock baseline.
- Prefer shell timing because it includes Python startup, Django import time, test discovery, database setup, and teardown.
- Record the exact command, environment, and repeat count.
-
Separate framework phases when possible.
- For Django's runner, use
--timingto see database setup and teardown. - For pytest, compare shell timing with
pytest --durations.
- For Django's runner, use
-
Find the slowest tests.
- For pytest-django, start with
pytest --durations 20. - For Django's runner, use an existing slow-test plugin or a small custom runner only when the project does not already have one.
- For pytest-django, start with