3 ms·
On a properly configured environment TSC is the default clocksource. I have no idea why one would want to precisely measure time with any other clock source. O
by bitcharmer 9y ago
On a properly configured environment TSC is the default clocksource. I have no idea why one would want to precisely measure time with any other clock source.
On relatively contemporary systems clock_gettime(CLOCK_REALTIME) will give you a nanosecond resolution wall clock time and the cost of going through JNI will cost you around 11-13ns, so with a simple native wrapper in java the cost is negligible.
Although interesting, the whole study of the cost of obtaining the current time in Java with currentTimeMillis() with clock sources other than TSC is somewhat irrelevant.
- usefulcat 9y agoThe Linux kernel may choose to not select TSC as the clocksource, regardless of the configuration. For example, we have a 4 socket machine running CentOS 6 that refuses to use the TSC timer because at boot time the kernel determines (experimentally, I believe) that TSC is not reliable on that hardware. So it falls back to using HPET instead. We also have a similar 2 socket machine running a similar version of CentOS that has no problems using TSC. ¯\_(ツ)_/¯