>
> To reproduce, on emscripten 1.36.5 (incoming branch)
>
 
(1) here is simple test case (c.cpp)
#include <chrono>
#include <iostream>


int
main()
{
    std::cout << "before" << std::endl;
    auto now = std::chrono::high_resolution_clock::now();
    std::cout << "after" << std::endl;
    return 0;
}

(2) Compile it using
 em++ c.cpp -o c.html

(3) In generated c.js, add following line as first line (To simulate 
Safari/IE/Edge webworker environment restriction on FF/Chrome)
performance={};

Output:
Only before is printed followed by exception (some implementations of 
boost::chrono::steady_clock::now may throw exception; but here we are using 
std::chrono )

Reason:

*__ZNSt3__26chrono12steady_clock3nowEv *(_std::__2::chrono::
*steady_clock::now(*))   calls (via invoke_ii)    *_clock_gettime(*clk_id 
=1,tp) 
*_clock_gettime *calls*_emscripten_get_now_is_monotonic* which return false
*_clock_gettime* then sets error number and return -1.
*__ZNSt3__26chrono12steady_clock3nowEv  *on seeing this error throws if 
exceptions are enabled *or *continue (with unexpected time value) if 
exceptions are disabled.
YES, _emscripten_get_now checks if performance exists and then uses a 
fallback but it is not called due to monotonicity test failure


Other consideration: 
As mentioned in comment, Date.now does not guarantee monotonicty and it may 
be issue depending on some implementation. An answer here indicate how 
Date.now can be forced to be monotonic:
http://stackoverflow.com/questions/7272395/monotonically-increasing-time-in-javascript



-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to