Accuracy is MS MS:
1 //Pseudo Code2 3 LongStarttime=system.currenttimemillis ();//Get start time4 5DoSomething ();//code snippet for testing6 7 LongEndtime=system.currenttimemillis ();//Get end Time8 9SYSTEM.OUT.PRINTLN ("program Run Time:" + (End-start) + "MS");Ten One //Pseudo Code A - LongStarttime=system.currenttimemillis ();//Get start time - theDoSomething ();//code snippet for testing - - LongEndtime=system.currenttimemillis ();//Get end Time - +SYSTEM.OUT.PRINTLN ("program Run Time:" + (End-start) + "MS");
The second is measured in nanoseconds:
1 //Pseudo Code2 3 LongStarttime=system.nanotime ();//Get start time4 5DoSomething ();//code snippet for testing6 7 LongEndtime=system.nanotime ();//Get end Time8 9SYSTEM.OUT.PRINTLN ("program Run Time:" + (End-start) + "ns");Ten One //Pseudo Code A - LongStarttime=system.nanotime ();//Get start time - theDoSomething ();//code snippet for testing - - LongEndtime=system.nanotime ();//Get end Time - +SYSTEM.OUT.PRINTLN ("program Run Time:" + (End-start) + "ns");
Java Basics __ Net Learning (26): A method of judging the execution time of a program in a program