The first is calculated in milliseconds. Java code//pseudocode
Copy the code code as follows:
long startTime=System.currentTimeMillis(); //Get the start time
doSomeThing(); //Tested code segment
long endTime=System.currentTimeMillis(); //Get the end time
System.out.println("Program running time: "+(end-start)+"ms");
The second is calculated in nanoseconds. Java code//pseudocode
Copy the code code as follows:
long startTime=System.nanoTime(); //Get the start time
doSomeThing(); //Tested code segment
long endTime=System.nanoTime(); //Get the end time
System.out.println("Program running time: "+(end-start)+"ns");