Re: [AD] Add timeBeginPeriod(1) to wtimer.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


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 exactly
the 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 to
> timeBeginPeriod
> > has 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)
> remains
> > active, which causes some overall slowdown of the whole program (as
> > mentioned 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 the
> current
> >>>implementation 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 call
> >>>to 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=453116
> >>>
> >>>As this is my very first contribution, please forgive if anything is 
> >>>not in
> >>>the right format or otherwise unexpected.
> >>>
> >>>Thanks for consideration!
> >>>
> >>>Best regards Tobias
> >>>
> >>>-- 
> >>>http://www.staedtebauen.de <http://www.staedtebauen.de/>
> >>>
> >>>
> >>>-------------------------------------------------------
> >>>SF email is sponsored by - The IT Product Guide
> >>>Read honest & candid reviews on hundreds of IT Products from real
> users.
> >>>Discover which products truly live up to the hype. Start reading now.
> >>>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click 
> >>><http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click>
> >>>-- 
> >>>https://lists.sourceforge.net/lists/listinfo/alleg-developers 
> >>
> >>
> >>
> >>-------------------------------------------------------
> >>SF email is sponsored by - The IT Product Guide
> >>Read honest & candid reviews on hundreds of IT Products from real users.
> >>Discover which products truly live up to the hype. Start reading now.
> >>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> >>-- 
> >>https://lists.sourceforge.net/lists/listinfo/alleg-developers
> >>
> > 
> > 
> > 
> > -------------------------------------------------------
> > SF email is sponsored by - The IT Product Guide
> > Read honest & candid reviews on hundreds of IT Products from real users.
> > Discover which products truly live up to the hype. Start reading now.
> > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> -- 
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
> 




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/