Return the computer time in nanoseconds in Java
Description
The following code shows how to return the computer time in nanoseconds.
Example
//from ww w . j a v a 2 s .co m
public class Main {
public static void main(String[] args) {
long start = System.nanoTime();
// block of code to time
long end = System.nanoTime();
System.out.println("It took " + (end - start) + " nanoseconds");
}
}
The code above generates the following result.