How to measure the a time-span in seconds using System.currentTimeMillis()?
long start = System.currentTimeMillis();counter.countPrimes(1000000);long end = System.currentTimeMillis();System.out.println("Took : " + ((end - start) / 1000));
UPDATE
An even more accurate solution would be:
final long start = System.nanoTime();counter.countPrimes(1000000);final long end = System.nanoTime();System.out.println("Took: " + ((end - start) / 1000000) + "ms");System.out.println("Took: " + (end - start)/ 1000000000 + " seconds");