// For Loop Counting and Timing Demo, M.S. Branicky, 09/20/2007
//
// Things to do: 
// - count to 3 billion
// - print out every million
// - add an inner loop

public class CountTimeDemo {
  public static void main (String[] args) {
    
    long i, j, count, startTime, endTime, elapsedTime;  // see Liang, p. 34
    
    count = 0;

    startTime = System.currentTimeMillis();             // see Liang, p. 51
    for (i=1; i<=1000000; i++) {
      count++;
    }
    endTime = System.currentTimeMillis();

    elapsedTime = endTime - startTime;

    System.out.println("Loop body was executed " + count + " times\n");
    System.out.println("Time elapsed (ms): " + elapsedTime );
    System.out.println("Time elapsed (s):  " + (elapsedTime/1000.0) );

  }
}
