Use of System.nanoTime() in Java

ns (nanosecond): Represents nanoseconds, a unit of time. One billionth of a second is equal to 10 seconds to the minus 9th power. Generally used as a unit of memory read and write speed.

1 nanosecond = 0.000001 milliseconds

1 nanosecond=0.000000001 second

System.nanoTime() in Java returns nanoseconds, and nanoTime returns any time, or even a negative number

The milliseconds returned by System.currentTimeMills() in Java. This millisecond is actually the number of milliseconds since January 1, 1970

long start=System.nanoTime();
long end=System.nanoTime();
System.out.println(end-start);

 

Guess you like

Origin blog.csdn.net/y_bccl27/article/details/114361469