Wednesday, January 20, 2010

basic program to print the execution time of a program

import java.util.*;
class execution_time
{
public static void main(String args[])
{
long startTime=System.currentTimeMillis();
execution_time obj = new execution_time();
obj.show();
long endTime=System.currentTimeMillis();
long t=endTime-startTime;
System.out.println("the execution time for this program is:"+t);
}
void show()
{
int i;
for(i=100;i<1001;i++)
{
System.out.print(i+" ");
}
System.out.println();
}
}

1 comment: