99 |
|
} |
100 |
|
} |
101 |
|
timer.finish(); |
102 |
< |
reallyAssert (sum == expect * iters); |
102 |
> |
reallyAssert(sum == expect * iters); |
103 |
|
} |
104 |
|
|
105 |
|
static void t1Boxed(String nm, int n, Map<Integer,Integer> s, Integer[] key, int expect) { |
112 |
|
} |
113 |
|
} |
114 |
|
timer.finish(); |
115 |
< |
reallyAssert (sum == expect * iters); |
115 |
> |
reallyAssert(sum == expect * iters); |
116 |
|
} |
117 |
|
|
118 |
|
|
123 |
|
if (s.remove(key[i]) != null) ++sum; |
124 |
|
} |
125 |
|
timer.finish(); |
126 |
< |
reallyAssert (sum == expect); |
126 |
> |
reallyAssert(sum == expect); |
127 |
|
} |
128 |
|
|
129 |
|
static void t3(String nm, int n, Map<Integer,Integer> s, Integer[] key, int expect) { |
135 |
|
if (s.put(k, v) == null) ++sum; |
136 |
|
} |
137 |
|
timer.finish(); |
138 |
< |
reallyAssert (sum == expect); |
138 |
> |
reallyAssert(sum == expect); |
139 |
|
} |
140 |
|
|
141 |
|
static void t4(String nm, int n, Map<Integer,Integer> s, Integer[] key, int expect) { |
145 |
|
if (s.containsKey(key[i])) ++sum; |
146 |
|
} |
147 |
|
timer.finish(); |
148 |
< |
reallyAssert (sum == expect); |
148 |
> |
reallyAssert(sum == expect); |
149 |
|
} |
150 |
|
|
151 |
|
static void t5(String nm, int n, Map<Integer,Integer> s, Integer[] key, int expect) { |
155 |
|
if (s.remove(key[i]) != null) ++sum; |
156 |
|
} |
157 |
|
timer.finish(); |
158 |
< |
reallyAssert (sum == expect); |
158 |
> |
reallyAssert(sum == expect); |
159 |
|
} |
160 |
|
|
161 |
|
static void t6(String nm, int n, Map<Integer,Integer> s, Integer[] k1, Integer[] k2) { |
166 |
|
if (s.get(k2[i & absentMask]) != null) ++sum; |
167 |
|
} |
168 |
|
timer.finish(); |
169 |
< |
reallyAssert (sum == n); |
169 |
> |
reallyAssert(sum == n); |
170 |
|
} |
171 |
|
|
172 |
|
static void t7(String nm, int n, Map<Integer,Integer> s, Integer[] k1, Integer[] k2) { |
177 |
|
if (s.containsKey(k2[i & absentMask])) ++sum; |
178 |
|
} |
179 |
|
timer.finish(); |
180 |
< |
reallyAssert (sum == n); |
180 |
> |
reallyAssert(sum == n); |
181 |
|
} |
182 |
|
|
183 |
|
static void t8(String nm, int n, Map<Integer,Integer> s, Integer[] key, int expect) { |
187 |
|
if (s.get(key[i]) != null) ++sum; |
188 |
|
} |
189 |
|
timer.finish(); |
190 |
< |
reallyAssert (sum == expect); |
190 |
> |
reallyAssert(sum == expect); |
191 |
|
} |
192 |
|
|
193 |
|
|
199 |
|
for (int i = 0; i < absentSize; i += step) |
200 |
|
if (s.containsValue(absent[i])) ++sum; |
201 |
|
timer.finish(); |
202 |
< |
reallyAssert (sum != 0); |
202 |
> |
reallyAssert(sum != 0); |
203 |
|
} |
204 |
|
|
205 |
|
|
211 |
|
if (ks.contains(key[i])) ++sum; |
212 |
|
} |
213 |
|
timer.finish(); |
214 |
< |
reallyAssert (sum == size); |
214 |
> |
reallyAssert(sum == size); |
215 |
|
} |
216 |
|
|
217 |
|
|
225 |
|
timer.finish(); |
226 |
|
// if (sum != size) |
227 |
|
// System.out.println("iters " + sum + " size " + size); |
228 |
< |
reallyAssert (sum == size); |
228 |
> |
reallyAssert(sum == size); |
229 |
|
} |
230 |
|
|
231 |
|
static void ittest2(Map<Integer,Integer> s, int size) { |
238 |
|
timer.finish(); |
239 |
|
// if (sum != size) |
240 |
|
// System.out.println("iters " + sum + " size " + size); |
241 |
< |
reallyAssert (sum == size); |
241 |
> |
reallyAssert(sum == size); |
242 |
|
} |
243 |
|
static void ittest3(Map<Integer,Integer> s, int size) { |
244 |
|
int sum = 0; |
248 |
|
++sum; |
249 |
|
} |
250 |
|
timer.finish(); |
251 |
< |
reallyAssert (sum == size); |
251 |
> |
reallyAssert(sum == size); |
252 |
|
} |
253 |
|
|
254 |
|
static void ittest4(Map<Integer,Integer> s, int size, int pos) { |
255 |
|
IdentityHashMap seen = new IdentityHashMap(size); |
256 |
< |
reallyAssert (s.size() == size); |
256 |
> |
reallyAssert(s.size() == size); |
257 |
|
int sum = 0; |
258 |
|
timer.start("Iter XEntry ", size); |
259 |
|
Iterator it = s.entrySet().iterator(); |
267 |
|
if (v != MISSING) |
268 |
|
++sum; |
269 |
|
} |
270 |
< |
reallyAssert (s.containsKey(k)); |
270 |
> |
reallyAssert(s.containsKey(k)); |
271 |
|
it.remove(); |
272 |
< |
reallyAssert (!s.containsKey(k)); |
272 |
> |
reallyAssert(!s.containsKey(k)); |
273 |
|
while (it.hasNext()) { |
274 |
|
Map.Entry<Integer,Integer> x = (Map.Entry<Integer,Integer>)(it.next()); |
275 |
|
Integer k2 = x.getKey(); |
278 |
|
++sum; |
279 |
|
} |
280 |
|
|
281 |
< |
reallyAssert (s.size() == size-1); |
281 |
> |
reallyAssert(s.size() == size-1); |
282 |
|
s.put(k, v); |
283 |
< |
reallyAssert (seen.size() == size); |
283 |
> |
reallyAssert(seen.size() == size); |
284 |
|
timer.finish(); |
285 |
< |
reallyAssert (sum == size); |
286 |
< |
reallyAssert (s.size() == size); |
285 |
> |
reallyAssert(sum == size); |
286 |
> |
reallyAssert(s.size() == size); |
287 |
|
} |
288 |
|
|
289 |
|
|
306 |
|
++sum; |
307 |
|
} |
308 |
|
timer.finish(); |
309 |
< |
reallyAssert (sum == size); |
309 |
> |
reallyAssert(sum == size); |
310 |
|
} |
311 |
|
|
312 |
|
static void entest2(Hashtable ht, int size) { |
317 |
|
++sum; |
318 |
|
} |
319 |
|
timer.finish(); |
320 |
< |
reallyAssert (sum == size); |
320 |
> |
reallyAssert(sum == size); |
321 |
|
} |
322 |
|
|
323 |
|
|
331 |
|
++sum; |
332 |
|
} |
333 |
|
timer.finish(); |
334 |
< |
reallyAssert (sum == size); |
334 |
> |
reallyAssert(sum == size); |
335 |
|
} |
336 |
|
|
337 |
|
static void entest4(Hashtable ht, int size) { |
343 |
|
++sum; |
344 |
|
} |
345 |
|
timer.finish(); |
346 |
< |
reallyAssert (sum == size); |
346 |
> |
reallyAssert(sum == size); |
347 |
|
} |
348 |
|
|
349 |
|
static void entest(Map<Integer,Integer> s, int size) { |
396 |
|
System.out.print(time + "ms"); |
397 |
|
|
398 |
|
if (s instanceof IdentityHashMap) return; |
399 |
< |
reallyAssert (s.equals(m)); |
399 |
> |
reallyAssert(s.equals(m)); |
400 |
|
} |
401 |
|
|
402 |
|
|
459 |
|
|
460 |
|
timer.start("Iter Equals ", size * 2); |
461 |
|
boolean eqt = s2.equals(s) && s.equals(s2); |
462 |
< |
reallyAssert (eqt); |
462 |
> |
reallyAssert(eqt); |
463 |
|
timer.finish(); |
464 |
|
|
465 |
|
timer.start("Iter HashCode ", size * 2); |
466 |
|
int shc = s.hashCode(); |
467 |
|
int s2hc = s2.hashCode(); |
468 |
< |
reallyAssert (shc == s2hc); |
468 |
> |
reallyAssert(shc == s2hc); |
469 |
|
timer.finish(); |
470 |
|
|
471 |
|
timer.start("Put (present) ", size * 2); |
479 |
|
if (s2.put(me.getKey(), me.getValue()) != null) |
480 |
|
++ipsum; |
481 |
|
} |
482 |
< |
reallyAssert (ipsum == s.size()); |
482 |
> |
reallyAssert(ipsum == s.size()); |
483 |
|
timer.finish(); |
484 |
|
|
485 |
|
timer.start("Iter EntrySet contains ", size * 2); |
490 |
|
if (es2.contains(entry)) ++sum; |
491 |
|
} |
492 |
|
timer.finish(); |
493 |
< |
reallyAssert (sum == size); |
493 |
> |
reallyAssert(sum == size); |
494 |
|
|
495 |
|
Integer hold = s2.get(key[size-1]); |
496 |
|
s2.put(key[size-1], absent[0]); |
497 |
|
timer.start("Iter Equals ", size * 2); |
498 |
|
eqt = s2.equals(s) && s.equals(s2); |
499 |
< |
reallyAssert (!eqt); |
499 |
> |
reallyAssert(!eqt); |
500 |
|
timer.finish(); |
501 |
|
|
502 |
|
timer.start("Iter HashCode ", size * 2); |
503 |
|
int s1h = s.hashCode(); |
504 |
|
int s2h = s2.hashCode(); |
505 |
< |
reallyAssert (s1h != s2h); |
505 |
> |
reallyAssert(s1h != s2h); |
506 |
|
timer.finish(); |
507 |
|
|
508 |
|
s2.put(key[size-1], hold); |
513 |
|
reallyAssert(es.remove(s2i.next())); |
514 |
|
timer.finish(); |
515 |
|
|
516 |
< |
reallyAssert (s.isEmpty()); |
516 |
> |
reallyAssert(s.isEmpty()); |
517 |
|
|
518 |
|
timer.start("Clear ", size); |
519 |
|
s2.clear(); |
520 |
|
timer.finish(); |
521 |
< |
reallyAssert (s2.isEmpty() && s.isEmpty()); |
521 |
> |
reallyAssert(s2.isEmpty() && s.isEmpty()); |
522 |
|
} |
523 |
|
|
524 |
|
static class TestTimer { |