The first is calculated in milliseconds.
Pseudo code long Starttime=system.currenttimemillis (); Get start time dosomething (); Test the code Snippet long Endtime=system.currenttimemillis (); Get End Time System.out.println ("program Run Time:" + (End-start) + "MS");//pseudo Code long Starttime=system.currenttimemillis (); Get start time dosomething (); Test the code Snippet long Endtime=system.currenttimemillis (); Get End Time System.out.println ("program Run Time:" + (End-start) + "MS");
The second is measured in nanoseconds.
Pseudo code long Starttime=system.nanotime (); Get start time dosomething (); Test the code Snippet long Endtime=system.nanotime (); Get End Time System.out.println ("program Run Time:" + (End-start) + "ns");//pseudo Code long Starttime=system.nanotime (); Get start time dosomething (); Test the code Snippet long Endtime=system.nanotime (); Get End Time System.out.println ("program Run Time:" + (End-start) + "ns");
Java Get program Execution time