14 Replies
Ok so made a bench setup, and I think this is fairly optimal.
I chose a bad rolling average here (10, but the period is 1 so it's now also wobbling)
goes around ~16.3 to 16.7 so I think it's pretty good for 60FPS
The "real" timings here are between 16ms and 17ms - not much to do there, that's just the resolution
CPU timings for this baseline - as expected this pins the CPU it's on (in green) to 100% (depicted is the idle CPU)
Did this now - CPU usage is minimal (picture follows)
(again idle times, green is the relevant CPU)
(also for some reason the viewer has pissed itself with this one)
but as you can probably not tell, CPU usage is minimal (< 5%)
I feel like dropping a few frames is fine? (I'd consider the 5 peaks you can see as "dropped frames" essentially)
Like, if you enable V-Sync this code should never run -> no dropped frames
and what I'm about to test, if you actually have performance problems, this code should also never run
!! Also - note that this test emulates a single-core system, the process is tied to a specific core, and as this relies on the OS to re-schedule as a little bit later, other processes may contest the one core we use, which then causes these dropped frames.
Tested the maxed CPU now, thanks to @khitiara, had to write the results to /dev/null or JIT would be smart.
Results look similar to the above, with a few dropped frames. CPU is pinned at nearly 100%, which is expected given the inner loop can't keep up.
^ This can still run at slightly above 60FPS, which is why we still see some drops from other processes contesting the core we use
here is something that can run at 10 or so FPS (not sure if my math is correct) - the limiter is still set to allow up to 60 FPS
as you can see, there are no "dropped" frames, I'd attribute any variance to the numbers being random and just general background noise.
I'm still not sure the occasional stutter is worth the tradeoff of just pinning a CPU thread, I'm really not sure
^ this is the entire code I used to make these measurements
If someone is interested in viewing the data the way I did, I used https://rerun.io + a small python script (can share that of course)
If we want to consider this as an actual replacement, we'd still have to test how this does in a 24h test, as a monotonic counter is involved for estimating the sleep time, which might overflow...
oh hello why aren't I in this thread