Comments re High resolution replacement for Sleep
#13
This is how it works when n>3

|-----  Sleep ( n-3 ) -----|-Poll Tix-|

Sleep ( n-3 ) has a resolution of 1ms by virtue of SetHiRes. However its value will vary between just over (n-3 )ms and about (n-3+1.5)ms and not the theoretical expectation of  (n-3+1).

So Sleep ( n-3 ) is a variable of an unknown quantity and has no CPU Load.

Sleep (n-3 ) + Poll Tix = qTarget.

It follows then 'Poll Tix' is also a variable of an unknown quantity but has a CPU Load.

If we rip out Sleep ( n-3  ) then we are reduced to polling Tix for the whole of the delay. For 'long' delays one of our cores will be running flat out and this may impact on our system performance.

One guy at FreeBASIC only polled Timer, and therefore the Performance Counter, and reckoned that worked for him. With a five-second delay, for example, and a quad-core, one of his cores would suffer a 25% CPU Load hit. That is huge. With Sleep (n-3 ) there would be no CPU Load associated with the delay for about five seconds minus about 3ms. A CPU Load would kick in for about 3ms which is negligible.
Reply


Messages In This Thread
RE: Comments re High resolution replacement for Sleep - by David Roberts - 09-14-2025, 05:34 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)