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.*; |
24 |
|
if (args.length > 0) { |
25 |
|
try { |
26 |
|
mapClass = Class.forName(args[0]); |
27 |
< |
} catch(ClassNotFoundException e) { |
27 |
> |
} catch (ClassNotFoundException e) { |
28 |
|
throw new RuntimeException("Class " + args[0] + " not found."); |
29 |
|
} |
30 |
|
} |
96 |
|
char[] c = new char[len * 4]; |
97 |
|
for (int j = 0; j < len; ++j) { |
98 |
|
int r = rng.next(); |
99 |
< |
c[k++] = (char)(' ' + (r & 0x7f)); |
99 |
> |
c[k++] = (char) (' ' + (r & 0x7f)); |
100 |
|
r >>>= 8; |
101 |
< |
c[k++] = (char)(' ' + (r & 0x7f)); |
101 |
> |
c[k++] = (char) (' ' + (r & 0x7f)); |
102 |
|
r >>>= 8; |
103 |
< |
c[k++] = (char)(' ' + (r & 0x7f)); |
103 |
> |
c[k++] = (char) (' ' + (r & 0x7f)); |
104 |
|
r >>>= 8; |
105 |
< |
c[k++] = (char)(' ' + (r & 0x7f)); |
105 |
> |
c[k++] = (char) (' ' + (r & 0x7f)); |
106 |
|
} |
107 |
|
key[i] = new String(c); |
108 |
|
} |
133 |
|
barrier.await(); |
134 |
|
barrier.await(); |
135 |
|
long time = timer.getTime(); |
136 |
< |
long tpo = time / (i * (long)nops); |
136 |
> |
long tpo = time / (i * (long) nops); |
137 |
|
System.out.print(LoopHelpers.rightJustify(tpo) + " ns per op"); |
138 |
< |
double secs = (double)(time) / 1000000000.0; |
138 |
> |
double secs = (double) time / 1000000000.0; |
139 |
|
System.out.println("\t " + secs + "s run time"); |
140 |
|
map.clear(); |
141 |
|
} |
148 |
|
int position; |
149 |
|
int total; |
150 |
|
|
151 |
< |
Runner(int id, Map<String,String> map, String[] key, CyclicBarrier barrier) { |
151 |
> |
Runner(int id, Map<String,String> map, String[] key, CyclicBarrier barrier) { |
152 |
|
this.map = map; |
153 |
|
this.key = key; |
154 |
|
this.barrier = barrier; |
158 |
|
} |
159 |
|
|
160 |
|
int step() { |
161 |
< |
// random-walk around key positions, bunching accesses |
161 |
> |
// random-walk around key positions, bunching accesses |
162 |
|
int r = rng.next(); |
163 |
|
position += (r & 7) - 3; |
164 |
|
while (position >= key.length) position -= key.length; |