I have been struggling with slow tests - really slow tests. I thought that was probably due to inefficient data setup within my tests. I did some 'before' time measurements and then, for unrelated reasons, squashed all my migrations. Then I ran my tests again. I did not change any of the test code - only the migrations - but the tests are dramatically faster. I had expected some improvement in the database setup number reported with --timing but I had not expected much change in the speed with which the tests themselves run. Can anyone offer an explanation for this?
Before
| Method |
DB setup |
DB teardown |
Running Test |
Total elapsed |
| MySQL |
124.2s |
3.6s |
794.5s |
925.0s |
| MySQL keepdb 1 |
123.8s |
0s |
742.5s |
869.2s |
| MySQL keepdb 2 |
4.3s |
0s |
742.2s |
759.1s |
| SQLite run 1 |
4.9s |
0s |
886.7s |
896.3s |
| SQLite run 2 |
4.3s |
0s |
778.1s |
785.2s |
After squashing migration
| Method |
DB setup |
DB teardown |
Running Test |
Total elapsed |
| MySQL |
107.8s |
6.5s |
200.0s |
319.5s |
| MySQL |
109.3s |
6.9s |
205.3s |
326.4s |
| SQLite run 1 |
34.3s |
0s |
128.2s |
166.9s |
| SQLite run 2 |
1.5s |
0s |
124.6s |
130.3s |