1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import java.util.*; |
28 |
|
int t = (args.length <= 2) ? DEFAULT_TRIALS : Integer.parseInt(args[2]); |
29 |
|
|
30 |
|
System.out.print("Class: " + klass.getName()); |
31 |
< |
System.out.print(" ~iters: " + (long)n * (long)n); |
31 |
> |
System.out.print(" ~iters: " + (long) n * (long) n); |
32 |
|
System.out.print(" trials: " + t); |
33 |
|
System.out.println(); |
34 |
|
|
65 |
|
preload(n); |
66 |
|
long startTime = System.nanoTime(); |
67 |
|
long count = traversals(n); |
68 |
< |
double elapsed = (double)(System.nanoTime() - startTime); |
68 |
> |
double elapsed = (double) (System.nanoTime() - startTime); |
69 |
|
double npi = elapsed / count; |
70 |
|
double secs = elapsed / 1000000000; |
71 |
|
System.out.printf("%7.1f ns/iter %8.3fs run time\n", npi, secs); |
74 |
|
long traversals(int n) { |
75 |
|
long count = 0; |
76 |
|
long check = 0; |
77 |
< |
for (int i = 0; i < n; i++) { |
77 |
> |
for (int i = 0; i < n; i++) { |
78 |
|
check += elementCount; |
79 |
|
count += counts(); |
80 |
|
maybeAdd(); |