Wednesday, October 19, 2011

Simple Java program to test how much time an action takes

public class TimeTest {
public static void main(String[] args) {
int count = 0;
long startTime;
startTime = System.currentTimeMillis();
while (count < Integer.MAX_VALUE) {
count++;
if (count % 1000 == 0) {
System.out.println(count);
}
}
System.out.println("Time in ms: "+ (System.currentTimeMillis() - startTime));
}
}

No comments:

Post a Comment