News for hackers. Stuff that matters.
Re:Game Timers: Issues and Solutions (2012) by devwastaken on Tuesday August 17, 2021 @11:19AM (#28210823)
What's preventing PC's from having some realtime clock hardware component that could be used by software?
Re:Game Timers: Issues and Solutions (2012) by flohofwoe on Tuesday August 17, 2021 @01:33PM (#28212541)
This isn't the problem, those timers exist and are accessible (unless you're in a web browser). The problem is that your code is essentially running at an unpredictable point in time within the current frame. E.g. if you measure the time duration between the same line of code at the start of your per-frame function you'll get a tiny jitter and never exactly 16.66667 ms (assuming a 60Hz display). I'm not sure what's the exact reason, but I guess there are many things that can throw off this sort of time measurement in a modern operating system (for instance process/thread scheduling).
Re:Game Timers: Issues and Solutions (2012) by krona on Tuesday August 17, 2021 @11:41AM (#28211095)
Modern CPU's already have several counters for 'nominal' cycles (i.e. cycles at a constant frequency). e.g. TSC instructions and Performance-Monitoring Counters.

Converting nominal cycles to time can be unreliable in some cases but not impossible.