node-sleep
node-sleep copied to clipboard
usleep deviation was too large
1 sec =1,000 millisec=1,000,000 microsec=1,000,000,000 nanosec
I have a code like this:
start = get_start_time();
usleep(100000); // sleep 100000 microsecond (or 100 millisecond).
end = get_end_time();
diff = end - start;
assert(80000 < diff && diff < 120000); // I think the deviation should be (-20%, 20%).
This code always runs successfully on my own computer (Linux, Windows and Mac). On travis-CI, it only succeeded on Linux and Windows, but not on Mac. The test code is here, and the CI result is here.
Why failed on MacOS? Are there any issues with the clock of Mac virtual machine?