32 |
|
if (args.length > 0) { |
33 |
|
try { |
34 |
|
setClass = Class.forName(args[0]); |
35 |
< |
} catch(ClassNotFoundException e) { |
35 |
> |
} catch (ClassNotFoundException e) { |
36 |
|
throw new RuntimeException("Class " + args[0] + " not found."); |
37 |
|
} |
38 |
|
} |
70 |
|
|
71 |
|
static NavigableSet newSet(Class cl) { |
72 |
|
try { |
73 |
< |
NavigableSet m = (NavigableSet)cl.newInstance(); |
73 |
> |
NavigableSet m = (NavigableSet) cl.newInstance(); |
74 |
|
return m; |
75 |
< |
} catch(Exception e) { |
75 |
> |
} catch (Exception e) { |
76 |
|
throw new RuntimeException("Can't instantiate " + cl + ": " + e); |
77 |
|
} |
78 |
|
} |
96 |
|
} |
97 |
|
} |
98 |
|
timer.finish(); |
99 |
< |
reallyAssert (sum == expect * iters); |
99 |
> |
reallyAssert(sum == expect * iters); |
100 |
|
} |
101 |
|
|
102 |
|
static void t2(String nm, int n, NavigableSet s, Integer[] key, int expect) { |
106 |
|
if (s.remove(key[i])) ++sum; |
107 |
|
} |
108 |
|
timer.finish(); |
109 |
< |
reallyAssert (sum == expect); |
109 |
> |
reallyAssert(sum == expect); |
110 |
|
} |
111 |
|
|
112 |
|
static void t3(String nm, int n, NavigableSet s, Integer[] key, int expect) { |
116 |
|
if (s.add(key[i])) ++sum; |
117 |
|
} |
118 |
|
timer.finish(); |
119 |
< |
reallyAssert (sum == expect); |
119 |
> |
reallyAssert(sum == expect); |
120 |
|
} |
121 |
|
|
122 |
|
static void t4(String nm, int n, NavigableSet s, Integer[] key, int expect) { |
126 |
|
if (s.contains(key[i])) ++sum; |
127 |
|
} |
128 |
|
timer.finish(); |
129 |
< |
reallyAssert (sum == expect); |
129 |
> |
reallyAssert(sum == expect); |
130 |
|
} |
131 |
|
|
132 |
|
static void t5(String nm, int n, NavigableSet s, Integer[] key, int expect) { |
136 |
|
if (s.remove(key[i])) ++sum; |
137 |
|
} |
138 |
|
timer.finish(); |
139 |
< |
reallyAssert (sum == expect); |
139 |
> |
reallyAssert(sum == expect); |
140 |
|
} |
141 |
|
|
142 |
|
static void t6(String nm, int n, NavigableSet s, Integer[] k1, Integer[] k2) { |
147 |
|
if (s.contains(k2[i & absentMask])) ++sum; |
148 |
|
} |
149 |
|
timer.finish(); |
150 |
< |
reallyAssert (sum == n); |
150 |
> |
reallyAssert(sum == n); |
151 |
|
} |
152 |
|
|
153 |
|
static void t7(String nm, int n, NavigableSet s, Integer[] k1, Integer[] k2) { |
158 |
|
if (s.contains(k2[i & absentMask])) ++sum; |
159 |
|
} |
160 |
|
timer.finish(); |
161 |
< |
reallyAssert (sum == n); |
161 |
> |
reallyAssert(sum == n); |
162 |
|
} |
163 |
|
|
164 |
|
static void t8(String nm, int n, NavigableSet s, Integer[] key, int expect) { |
168 |
|
if (s.contains(key[i])) ++sum; |
169 |
|
} |
170 |
|
timer.finish(); |
171 |
< |
reallyAssert (sum == expect); |
171 |
> |
reallyAssert(sum == expect); |
172 |
|
} |
173 |
|
|
174 |
|
|
182 |
|
e = s.higher(e); |
183 |
|
} |
184 |
|
timer.finish(); |
185 |
< |
reallyAssert (sum == iters); |
185 |
> |
reallyAssert(sum == iters); |
186 |
|
} |
187 |
|
|
188 |
|
static void lowerTest(NavigableSet s) { |
195 |
|
e = s.higher(e); |
196 |
|
} |
197 |
|
timer.finish(); |
198 |
< |
reallyAssert (sum == iters); |
198 |
> |
reallyAssert(sum == iters); |
199 |
|
} |
200 |
|
|
201 |
|
static void ceilingTest(NavigableSet s) { |
209 |
|
++sum; |
210 |
|
} |
211 |
|
timer.finish(); |
212 |
< |
reallyAssert (sum == iters); |
212 |
> |
reallyAssert(sum == iters); |
213 |
|
} |
214 |
|
|
215 |
|
static void floorTest(NavigableSet s) { |
223 |
|
++sum; |
224 |
|
} |
225 |
|
timer.finish(); |
226 |
< |
reallyAssert (sum == iters-1); |
226 |
> |
reallyAssert(sum == iters-1); |
227 |
|
} |
228 |
|
|
229 |
|
|
234 |
|
if (s.contains(key[i])) ++sum; |
235 |
|
} |
236 |
|
timer.finish(); |
237 |
< |
reallyAssert (sum == size); |
237 |
> |
reallyAssert(sum == size); |
238 |
|
} |
239 |
|
|
240 |
|
|
242 |
|
int sum = 0; |
243 |
|
timer.start("Iter Key ", size); |
244 |
|
for (Iterator it = s.iterator(); it.hasNext(); ) { |
245 |
< |
if(it.next() != MISSING) |
245 |
> |
if (it.next() != MISSING) |
246 |
|
++sum; |
247 |
|
} |
248 |
|
timer.finish(); |
249 |
< |
reallyAssert (sum == size); |
249 |
> |
reallyAssert(sum == size); |
250 |
|
} |
251 |
|
|
252 |
|
static void ittest(NavigableSet s, int size) { |
257 |
|
int sum = 0; |
258 |
|
timer.start("Desc Iter Key ", size); |
259 |
|
for (Iterator it = s.descendingIterator(); it.hasNext(); ) { |
260 |
< |
if(it.next() != MISSING) |
260 |
> |
if (it.next() != MISSING) |
261 |
|
++sum; |
262 |
|
} |
263 |
|
timer.finish(); |
264 |
< |
reallyAssert (sum == size); |
264 |
> |
reallyAssert(sum == size); |
265 |
|
} |
266 |
|
|
267 |
|
static void rittest(NavigableSet s, int size) { |
292 |
|
|
293 |
|
timer.start("Iter Equals ", size * 2); |
294 |
|
boolean eqt = s2.equals(s) && s.equals(s2); |
295 |
< |
reallyAssert (eqt); |
295 |
> |
reallyAssert(eqt); |
296 |
|
timer.finish(); |
297 |
|
|
298 |
|
timer.start("Iter HashCode ", size * 2); |
299 |
|
int shc = s.hashCode(); |
300 |
|
int s2hc = s2.hashCode(); |
301 |
< |
reallyAssert (shc == s2hc); |
301 |
> |
reallyAssert(shc == s2hc); |
302 |
|
timer.finish(); |
303 |
|
|
304 |
|
timer.start("Add (present) ", size); |
312 |
|
timer.start("Iter Equals ", size * 2); |
313 |
|
eqt = s2.equals(s) && s.equals(s2); |
314 |
|
if (as2) |
315 |
< |
reallyAssert (!eqt); |
315 |
> |
reallyAssert(!eqt); |
316 |
|
timer.finish(); |
317 |
|
|
318 |
|
timer.start("Iter HashCode ", size * 2); |
319 |
|
int s1h = s.hashCode(); |
320 |
|
int s2h = s2.hashCode(); |
321 |
|
if (as2) |
322 |
< |
reallyAssert (s1h != s2h); |
322 |
> |
reallyAssert(s1h != s2h); |
323 |
|
timer.finish(); |
324 |
|
|
325 |
|
timer.start("Clear ", size); |
326 |
|
s.clear(); |
327 |
|
s2.clear(); |
328 |
|
timer.finish(); |
329 |
< |
reallyAssert (s2.isEmpty() && s.isEmpty()); |
329 |
> |
reallyAssert(s2.isEmpty() && s.isEmpty()); |
330 |
|
} |
331 |
|
|
332 |
|
|
371 |
|
|
372 |
|
static void printStats() { |
373 |
|
for (Iterator it = accum.entrySet().iterator(); it.hasNext(); ) { |
374 |
< |
Map.Entry e = (Map.Entry)(it.next()); |
375 |
< |
Stats stats = ((Stats)(e.getValue())); |
374 |
> |
Map.Entry e = (Map.Entry) it.next(); |
375 |
> |
Stats stats = (Stats) e.getValue(); |
376 |
|
int n = stats.number; |
377 |
|
double t; |
378 |
|
if (n > 0) |
408 |
|
void finish() { |
409 |
|
long endTime = System.currentTimeMillis(); |
410 |
|
long time = endTime - startTime; |
411 |
< |
double timePerOp = ((double)time)/numOps; |
411 |
> |
double timePerOp = (double) time / numOps; |
412 |
|
|
413 |
|
Object st = accum.get(name); |
414 |
|
if (st == null) |