I have a simple cross-platform timing header here which uses the "most 
accurate time source" on each system:

https://github.com/floooh/sokol/blob/master/sokol_time.h

...however be warned that performance.now() is deliberately inaccurate in 
browsers since the Spectre/Meltdown apocalypse.

Precision is different in each browser (e.g. Firefox and Safari seem to 
round to the nearest millisecond), and there may be a random jitter added.


On Tuesday, 21 May 2019 01:36:28 UTC+2, Steven Johnson wrote:
>
> ...three years later, looks like this bug is still alive and well in 
> Emscripten (I found it via compiling wasm, not asm.js).
>
> I need something like steady_clock() to use for a simple code-benchmarking 
> setup; if I can't rely on std::chrono, what's the recommended replacement?
>
>
>
> On Monday, July 25, 2016 at 3:24:48 AM UTC-7, Gaurav Dewan wrote:
>>
>> Based on quick read of C++ specs (although more thorough reading of C++ 
>> specs would be required), 
>> (1) std::chrono::high_resolution_clock::now is declared to be 
>> no-except(cannot throw exceptions). 
>> (2) high_resolution_-clock may be a synonym for system_clock or 
>> steady_clock
>>
>> When calling this function in Safari ASM.JS worker(Mac), 
>> The test program is same as:
>> https://github.com/kripken/emscripten/issues/2980
>> It's just that this asm.js is loaded from javascript webworker.
>>
>> Function *__ZNSt3__16chrono12steady_clock3nowE *calls 
>> *__ZNSt3__120__throw_system_errorEiPKc 
>> (via *invoke_vii).
>> Shouldn't emscripten fallback to Date.now() if Performance.now() is not 
>> implemented ?
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/29d170e4-746e-4915-a8b7-0b2638dcb3f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to