#12389 closed (fixed)
performance enhancement for testsuite
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In my profiling of the test suite get_models appears to be the lowest hanging fruit. Attached is a patch that gives about a 30-35% speed increase for the django testsuite and closer to 40% for Ellington's suite.
Attachments (1)
Change History (7)
by , 15 years ago
Attachment: | get_models_caching.diff added |
---|
comment:1 by , 15 years ago
Component: | Testing framework → Core framework |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 15 years ago
FYI, I tweaked the patch in a few ways, in the spirit of micro-optimisation:
- Used try/except to avoid doing two dictionary lookups.
- Moved cache check before
self._populate()
call. - Used a tuple as the cache key, rather than a string, mainly for simplicity and clarity.
Only the last of these had any measurable effect at all, and not much, but they made me feel better :-)
comment:4 by , 15 years ago
Using a tuple helped? That's suprising, CPython dictionaries have some specific optimizations for when strings are used.
comment:5 by , 15 years ago
I did some timeit benchmarks and it is quicker -- because of the skipping of the creation of the string -- if you already have the string the string lookup is about twice as fast as the tuple lookup (both super quick though).
Though this patch helps testing I've changed the component since the change is actually in DB loading.