The reason why you are dropping off to 0% is because there is no workload in that demonstration loop. So it appears oddly to be 100% effective. The 1ms (probably not really 1ms by the way) dominates the loop since nothing else is happening causing you to be "sleeping" 99% of the time. A real game would not do this and this exact function would not have much impact. Basically if you are aiming for 60 frames per second, you have about 16ms per frame. So if you get things done early that frame then you need the delay to be scaled to fill that remaining time instead of hard coding 1ms. Additionally you might actually want to undercut the scaled value by 1ms.
Additionally I noticed that coming out of the
Sleep Sync you need to call
Sleep Sync 0 to turn it off. When your frame rate dips too low where you don't want any
Sleep Sync effect it will continue to eat frame rate unless turned off. I am hazy a little on this, but you might not be able to turn it off with that command if you just used the command to delay a few ms. You might need to
Sync draw the frame, not delay any ms on that frame and then use
Sleep Sync 0 . This is why my examples specifically use
Sleep Sync 0 when there is meant to be no delay rather than merely omitting the command entirely for that frame.
So this is an excellent suggestionZep/Zero32 provided, but purely as is, it only works as a demo. It would need some extras to work in a full game.
For your benefit and anyone years from now using forum search:
I explored
Sync Sleep with demos on several occasions.
Here I demonstrate the use. I also took the concept further, if the program is not real time why not have it sleep all the time until something is pressed.
https://forum.thegamecreators.com/thread/202812
Modular Code Library also has a version of this that has additional commands for enable/disable/set frame limit, also optionally manages camera sync mask:
https://forum.thegamecreators.com/thread/220759
WickedX wrote: "Dbro's Sync Sleep function sets a flag used in the internal loop that calls the sleep function. You do not need to use it in the do loop."
I have not seen the underlying low level code, and I speak only from using this in high level situations.
I'll also mention that there is another school of thought that says, sneak in some extra processing if you have spare time on each frame, which is almost never mentioned.