slow autoplay of missing tapes & levels
Posted: Tue Oct 05, 2021 6:37 am
I have long noticed a slowness in autoplay of certain levelsets. If there are some tapes for a levelset, but not as many as levels exist; or if a levelset's .conf claims to have a certain number of levels (say, 100), but actually has fewer (say, 81) -- then the empty 'playing' of the missing tapes or levels is slow.
For instance, I have a (non-solving) tape for level 0 of dx_dc2classic, but none of the other 99 levels. Running:
$ rocksndiamonds --mytapes -e "autotest dx_dc2classic"
takes 6.05s of realtime; the printing of 99 '(no tape found)' lines is visually slow; while:
$ rocksndiamonds --mytapes -e "autotest dx_dc2classic 0"
takes only 3.08s. And most interestingly,
$ rocksndiamonds --mytapes -e "autotest dx_dc2classic $(seq -s ' ' 1 99)"
takes 0.78s to 'play' 99 missing level tapes, reeling out the 99 '(no tape found)' lines at high speed!
Where did the missing 2.3 seconds disappear to?
After a lot of poking around, I determined that in the 1-level case, InitElementPropertiesEngine() is called 3x, and InitElementGraphicInfo() 2x; in the 100-level case (1 tape + 99 missing), they are called 102 & 101 times. That seems reasonable. But then in the 99-blank-tapes case, they are called 100 & 1 time!
The end of InitElementPropertiesEngine() is:
// this is needed because some graphics depend on element properties
if (game_status == GAME_MODE_PLAYING)
InitElementGraphicInfo();
and I guess `game_status == GAME_MODE_PLAYING` after the end of the level-0 tape.
Should this be fixed by:
- end-of-tape / end-of-level-run code setting `game_status` to some other value?
- InitElementGraphicInfo() setting it to some other value?
- something else?
For instance, I have a (non-solving) tape for level 0 of dx_dc2classic, but none of the other 99 levels. Running:
$ rocksndiamonds --mytapes -e "autotest dx_dc2classic"
takes 6.05s of realtime; the printing of 99 '(no tape found)' lines is visually slow; while:
$ rocksndiamonds --mytapes -e "autotest dx_dc2classic 0"
takes only 3.08s. And most interestingly,
$ rocksndiamonds --mytapes -e "autotest dx_dc2classic $(seq -s ' ' 1 99)"
takes 0.78s to 'play' 99 missing level tapes, reeling out the 99 '(no tape found)' lines at high speed!
Where did the missing 2.3 seconds disappear to?
After a lot of poking around, I determined that in the 1-level case, InitElementPropertiesEngine() is called 3x, and InitElementGraphicInfo() 2x; in the 100-level case (1 tape + 99 missing), they are called 102 & 101 times. That seems reasonable. But then in the 99-blank-tapes case, they are called 100 & 1 time!
The end of InitElementPropertiesEngine() is:
// this is needed because some graphics depend on element properties
if (game_status == GAME_MODE_PLAYING)
InitElementGraphicInfo();
and I guess `game_status == GAME_MODE_PLAYING` after the end of the level-0 tape.
Should this be fixed by:
- end-of-tape / end-of-level-run code setting `game_status` to some other value?
- InitElementGraphicInfo() setting it to some other value?
- something else?