Thursday, July 15, 2010

Measuring time(in ms) for particular operation in java

public class TimeMeasure {
public static void main(String arg[])
{
long startOperation = System.currentTimeMillis();

// Some operation

long endOperation = System.currentTimeMillis();
long timeTaken = endOperation - startOperation;
//long timeTaken = System.currentTimeMillis()-startOperation;
System.out.println("Time taken = "+timeTaken+" ms");
}
}

No comments:

Post a Comment