Can Time::getMillisecondCounterHiRes() be inaccurate on macOS?


#1

I have a test in my render loop to make sure it’s not taking too long, it recently started failing and I can’t see any reason why. I have one oscillator running, shouldn’t be using much CPU at all. Profiler doesn’t show much CPU usage either. But occasionally my test reports that my render loop is taking 62ms (and always 62ms). With a block size of 128, it should take 2.9ms. You’d think if it was taking 62ms I’d hear a click, but I don’t hear anything. Only think I can think is the clock isn’t returning accurate values. Anybody else experience this?


#2

Don’t remember hearing about anything like that before… it seems a bit strange… Definitely not the debugger getting in the way?


#3

Yeah, I’ve used this function for years, never dad an issue. I rewrote my test using std::chrono::high_resolution_clock and I no longer see an issue.


#4

How bizarre - our implementation is just a straight call to mach_absolute_time(), it seems hard to believe that wouldn’t be stable! We’ll do a bit of digging…


#5

No problems here on macOS, gives consistent and realistic sub-millisecond results.