long start = System.nanoTime();
sum_slow();
long end = System.nanoTime();
long diff = end - start;
System.out.println("Time: " + diff / 1000000000.0 + " seconds");
System.out.println("Time: " + TimeUnit.SECONDS.convert(diff, TimeUnit.NANOSECONDS) + " seconds");
Test:
Time: 18.596630883 seconds
Time: 18 seconds
No comments:
Post a Comment