18 |
|
int maxStages = 8; |
19 |
|
int items = 1000000; |
20 |
|
|
21 |
< |
Class klass = null; |
21 |
> |
Class<?> klass = null; |
22 |
|
if (args.length > 0) { |
23 |
|
try { |
24 |
|
klass = Class.forName(args[0]); |
43 |
|
Thread.sleep(100); |
44 |
|
print = true; |
45 |
|
|
46 |
< |
int k = 1; |
47 |
< |
for (int i = 1; i <= maxStages;) { |
46 |
> |
for (int k = 1, i = 1; i <= maxStages;) { |
47 |
|
oneRun(klass, i, items); |
48 |
|
if (i == k) { |
49 |
|
k = i << 1; |
116 |
|
} |
117 |
|
} |
118 |
|
|
119 |
< |
static void oneRun(Class klass, int n, int items) throws Exception { |
119 |
> |
static void oneRun(Class<?> klass, int n, int items) throws Exception { |
120 |
|
Deque<Integer> q = (Deque<Integer>) klass.newInstance(); |
121 |
|
LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); |
122 |
|
CyclicBarrier barrier = new CyclicBarrier(n + 1, timer); |
140 |
|
System.out.println(LoopHelpers.rightJustify(time / (items * n)) + " ns per item"); |
141 |
|
if (total == 0) // avoid overoptimization |
142 |
|
System.out.println("useless result: " + total); |
144 |
– |
|
143 |
|
} |
144 |
|
} |