package day3_4;
import java.util.Date;
/**
* Write a program which prints the time duration of executing one method.
*
* @author Ritesh
*
*/
public class CheckTime {
// simply prings message, used to calculate delay of execution
public static void calcDelay() {
System.out.println("Waiting...");
for (int i = 0; i < class="SpellE">i++) {
}
System.out.println("Stopped..");
}
/**execution begin from here
* @param args
* commandline arguments
*/
public static void main(String[] args) {
try {
// store the starting time in milisecond
long lngDelay = new Date().getTime();
// call the method
calcDelay();
// store the ending time in millisecond
lngDelay = new Date().getTime() - lngDelay;
System.out.println("Delay To Execute A Method Is :: " + lngDelay);
} catch (Exception e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment