How long it takes for one second in Java? Measure latency time in Java
问题 I don't want to change this code, I'm only interested in JVM, OS or kernel customization/configuration for best results! I have one second loop (1000 x 1ms) public static void main(String[] args) throws InterruptedException { long start = System.nanoTime(); for (int i = 0; i < 1000; i++ ) { Thread.sleep(TimeUnit.MILLISECONDS.toMillis(1)); } long duration = System.nanoTime() - start; System.out.println("Loop duration " + duration / TimeUnit.MILLISECONDS.toNanos(1) + " ms."); } On my Fedora 20