32 |
|
static int random(int bound) { |
33 |
|
return (random() & 0x7fffffff) % bound; |
34 |
|
} |
35 |
< |
|
35 |
> |
|
36 |
|
public static void main(String[] args) throws Exception { |
37 |
|
Class<?> cls = Class.forName(args[0]); |
38 |
|
long startTime = System.nanoTime(); |
39 |
|
for (int j = 0; j < 200; ++j) { |
40 |
|
@SuppressWarnings("unchecked") |
41 |
< |
Deque<Integer> deque = (Deque<Integer>) cls.newInstance(); |
41 |
> |
Deque<Integer> deque = |
42 |
> |
(Deque<Integer>) cls.getConstructor().newInstance(); |
43 |
|
nextTail = 0; |
44 |
|
nextHead = -1; |
45 |
|
mainTest(deque, (random() & ((1 << 20) - 1))); |
49 |
|
long now = System.nanoTime(); |
50 |
|
long elapsedTimeMillis = (now - startTime) / (1000L * 1000L); |
51 |
|
System.out.printf("\ntotal time %d ms\n", elapsedTimeMillis); |
52 |
< |
|
52 |
> |
|
53 |
|
} |
54 |
|
|
55 |
|
static void mainTest(Deque<Integer> deque, int n) throws Exception { |