Monday 7 February 2011

Measuring time taken by the program in java

long startTime = System.currentTimeMillis();

for (int i=0; i<1000; i++) {

methodUnderTest();

}

System.out.println("Avg. method execution time=" +

((System.currentTimeMillis() - startTime)/1000));

No comments:

Post a Comment