Re: [AD] Add timeBeginPeriod(1) to wtimer.c |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
aj. Tobias Scheuer wrote:
I think it affects the timers more generally, so it also affects the timers in allegro's separate timer threads. Didn't go into all the details, and I don't have a decent profiler at home, so I couldn't find out where exactlythe slowdown comes from. Maybe I should try to Quantify this at work...it changes the resolution of the rest() and timeGetTime() but it doesn't slow down the app itself.how could it ? Tobias Scheuer wrote:I have tried that. The documentation says that each call totimeBeginPeriodhas to be matched by a call to timeEndPeriod, so that#s why I have also called that function. If I leave that out, the timeBeginPeriod(1)remainsactive, which causes some overall slowdown of the whole program (asmentioned in the forum).timeBeginPeriod only needs to be called once for the whole process. not each time rest is called.Hi all, as already discussed in the forum, I would propose to change thecurrentimplementation of tim_win32_rest in wtimer.c to the following: [code] /* tim_win32_rest: * Rests the specified amount of milliseconds. */ static void tim_win32_rest(unsigned int time, AL_METHOD(void, callback, (void))) { unsigned int start; unsigned int ms = time; const MMRESULT rc = timeBeginPeriod(1); if (callback) { start = timeGetTime(); while (timeGetTime() - start < ms) (*callback)(); } else { Sleep(ms); } if( rc == TIMERR_NOERROR ) timeEndPeriod(1); } [/code]The new lines are the call to timeBeginPeriod(1); and the correcponding callto timeEndPeriod(1); in case the first call was successful.This affects only windows, and increases the accuracy of calls to rest(n).For the discussions, refer to the following threads: http://www.allegro.cc/forums/view_thread.php?_id=456146 http://www.allegro.cc/forums/view_thread.php?_id=453116As this is my very first contribution, please forgive if anything is not inthe right format or otherwise unexpected. Thanks for consideration! Best regards Tobias --
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |