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.*; |
14 |
|
* and long iterators. Reports include times for adds and other |
15 |
|
* checks, so overestimate times per iteration. |
16 |
|
*/ |
17 |
– |
|
17 |
|
public final class IteratorLoops { |
18 |
|
static final int DEFAULT_SIZE = 16384; |
19 |
|
static final int DEFAULT_TRIALS = 4; |
22 |
|
static int randomSeed = 3122688; |
23 |
|
|
24 |
|
public static void main(String[] args) throws Exception { |
25 |
< |
Class klass = Class.forName(args[0]); |
25 |
> |
Class<?> klass = Class.forName(args[0]); |
26 |
|
int n = (args.length <= 1) ? DEFAULT_SIZE : Integer.parseInt(args[1]); |
27 |
|
int t = (args.length <= 2) ? DEFAULT_TRIALS : Integer.parseInt(args[2]); |
28 |
|
|
73 |
|
long traversals(int n) { |
74 |
|
long count = 0; |
75 |
|
long check = 0; |
76 |
< |
for (int i = 0; i < n; i++) { |
76 |
> |
for (int i = 0; i < n; i++) { |
77 |
|
check += elementCount; |
78 |
|
count += counts(); |
79 |
|
maybeAdd(); |
122 |
|
try { Thread.sleep(500); } |
123 |
|
catch (Exception ex) { return; } |
124 |
|
} |
126 |
– |
|
127 |
– |
|
125 |
|
} |