7 |
|
* @test |
8 |
|
* @synopsis Times and checks basic map operations |
9 |
|
*/ |
10 |
– |
import java.util.*; |
10 |
|
import java.io.*; |
11 |
+ |
import java.util.*; |
12 |
|
|
13 |
|
public class NavigableMapCheck { |
14 |
|
|
37 |
|
} |
38 |
|
} |
39 |
|
|
40 |
– |
|
40 |
|
if (args.length > 1) |
41 |
|
numTests = Integer.parseInt(args[1]); |
42 |
|
|
45 |
|
|
46 |
|
System.out.println("Testing " + mapClass.getName() + " trials: " + numTests + " size: " + size); |
47 |
|
|
49 |
– |
|
48 |
|
absentSize = 8; |
49 |
|
while (absentSize < size) absentSize <<= 1; |
50 |
|
absentMask = absentSize - 1; |
57 |
|
for (int i = 0; i < size; ++i) |
58 |
|
key[i] = new Integer(i * 2 + 1); |
59 |
|
|
62 |
– |
|
60 |
|
for (int rep = 0; rep < numTests; ++rep) { |
61 |
|
runTest(newMap(mapClass), key); |
62 |
|
} |
74 |
|
} |
75 |
|
} |
76 |
|
|
80 |
– |
|
77 |
|
static void runTest(NavigableMap s, Integer[] key) { |
78 |
|
shuffle(key); |
79 |
|
int size = key.length; |
167 |
|
reallyAssert(sum == expect); |
168 |
|
} |
169 |
|
|
174 |
– |
|
170 |
|
static void t9(NavigableMap s) { |
171 |
|
int sum = 0; |
172 |
|
int iters = 20; |
232 |
|
reallyAssert(sum == iters-1); |
233 |
|
} |
234 |
|
|
240 |
– |
|
235 |
|
static void ktest(NavigableMap s, int size, Integer[] key) { |
236 |
|
timer.start("ContainsKey ", size); |
237 |
|
Set ks = s.keySet(); |
243 |
|
reallyAssert(sum == size); |
244 |
|
} |
245 |
|
|
252 |
– |
|
246 |
|
static void ittest1(NavigableMap s, int size) { |
247 |
|
int sum = 0; |
248 |
|
timer.start("Iter Key ", size); |
292 |
|
reallyAssert(sum == size); |
293 |
|
} |
294 |
|
|
302 |
– |
|
295 |
|
static void rittest(NavigableMap s, int size) { |
296 |
|
rittest1(s, size); |
297 |
|
// rittest2(s, size); |
298 |
|
} |
299 |
|
|
308 |
– |
|
300 |
|
static void rtest(NavigableMap s, int size) { |
301 |
|
timer.start("Remove (iterator) ", size); |
302 |
|
for (Iterator it = s.keySet().iterator(); it.hasNext(); ) { |
315 |
|
timer.finish(); |
316 |
|
} |
317 |
|
|
327 |
– |
|
318 |
|
static void dtest(NavigableMap s, int size, Integer[] key) { |
319 |
|
timer.start("Put (putAll) ", size * 2); |
320 |
|
NavigableMap s2 = null; |
381 |
|
reallyAssert(s2.isEmpty() && s.isEmpty()); |
382 |
|
} |
383 |
|
|
394 |
– |
|
395 |
– |
|
384 |
|
static void test(NavigableMap s, Integer[] key) { |
385 |
|
int size = key.length; |
386 |
|
|
442 |
|
startTime = System.currentTimeMillis(); |
443 |
|
} |
444 |
|
|
457 |
– |
|
445 |
|
String classify() { |
446 |
|
if (name.startsWith("Get")) |
447 |
|
return "Get "; |