There are two ways to test program code running in Java:
First: measured in milliseconds.
Long Starttime=system.currenttimemillis ();
Here are some test code
for (int i=0;i<10000;i++) {
System.out.println ("At present:" +i);
}
Long Endtime=system.currenttimemillis ();
SYSTEM.OUT.PRINTLN ("Current program time Consuming:" + (Endtime-starttime) + "MS");
Second: measured in nanoseconds.
Long Starttime=system.nanotime ();
Here are some test code
for (int i=0;i<10000;i++) {
System.out.println ("At present:" +i);
}
Long Endtime=system.nanotime ();
SYSTEM.OUT.PRINTLN ("Current program time Consuming:" + (Endtime-starttime) + "ns");
If the test program needs a high precise time, it will usually choose the second type,
If the test program needs general precise time, it will usually choose the first type,
Time Conversion:
1 hours = 60 Minutes
1 minutes = 60 seconds
1 seconds =1000 milliseconds
1 ms =1000 microseconds
1 microseconds =1000 nanosecond
1 nanoseconds =1000 Picosecond