peter-lawrey / Java-Thread-Affinity

Control thread affinity for Java
379 stars 77 forks source link

rdtsc versus System.currentTimeMillis() versus System.nanoTime() #33

Closed saoj closed 12 years ago

saoj commented 12 years ago

Hi Peter,

I have a call to System.currentTimeMillis() on my high-performance selector. I haven't measured how much latency it introduces but I was thinking about substituting it for your rdtsc implementation. Have you measured how much faster is rdtsc when compared to System.currentTimeMillis() and System.nanoTime() ?

Thanks!

-Sergio

peter-lawrey commented 12 years ago

Yes, but its highly dependant on the OS. On Centos 5.x its much faster 9 ns vs 180 ns and 15 ns vs 320 ns on another machine but on ubuntu 11.x it was 11 ns vs 22 ns. You should measure it by calling it repeatedly for about 2 seconds and taking an average.