-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What does the accuracy of timing functions depend on? The computer hardware? Simultaneously running programs? #8
Comments
But I also guess these are still negligible errors, since the header talks about e.g. sleep being at best at 55 \mu s accuracy: https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/c/timinglib.h#L114 |
Yes, both of those--probably mostly your hardware. Also, the Linux scheduler chosen to run this thread makes a huge difference. One more factor that makes a really big difference is the clock you choose to obtain timestamps. I specify You can see the various clock options here: https://man7.org/linux/man-pages/man3/clock_gettime.3.html For a rough estimate of the resolution for your computer with the concurrent events running and with the default /// Obtain an estimate, in nanoseconds, of the resolution of the underlying clock used to obtain all
/// of the timestamps above. This estimate is determined empirically through testing.
/// - Testing on my x86-64 Linux Ubuntu system shows my estimated timestamp resolution to be
/// ~15~30 ns. Run your own tests via "timinglib_get_resolution.c".
uint64_t get_estimated_resolution(); To turn on the Linux // Call this function to turn ON the Linux soft realtime scheduler for the
// calling thread, in order to get minimum sleep intervals and resolution of
// ~4 us with worst-case results being 100~400 us (0.1~0.4 ms), rather than the
// default minimum sleep time of ~55 us with worst-case results being ~8000 us
// (8 ms)! Calling this function allows for much better sleep resolutions and
// timing accuracies than the default `SCHED_OTHER` scheduler can provide!
void use_realtime_scheduler(); |
@mavavilj , how did you find this code by the way? |
What does the accuracy of timing functions depend on? The computer hardware? Simultaneously running programs? Something else?
I'm running https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/c/timinglib_timestamps_basic.c on an Elitebook 8470P and I see:
which seems to be 1) less accurate and 2) more jittery than the sample output.
The text was updated successfully, but these errors were encountered: