103 |
|
* class are found. |
104 |
|
*/ |
105 |
|
public void testComparableFamily() { |
106 |
+ |
int size = 500; // makes measured test run time -> 60ms |
107 |
|
ConcurrentHashMap<BI, Boolean> m = |
108 |
|
new ConcurrentHashMap<BI, Boolean>(); |
109 |
< |
for (int i = 0; i < 1000; i++) { |
109 |
> |
for (int i = 0; i < size; i++) { |
110 |
|
assertTrue(m.put(new CI(i), true) == null); |
111 |
|
} |
112 |
< |
for (int i = 0; i < 1000; i++) { |
112 |
> |
for (int i = 0; i < size; i++) { |
113 |
|
assertTrue(m.containsKey(new CI(i))); |
114 |
|
assertTrue(m.containsKey(new DI(i))); |
115 |
|
} |
120 |
|
* on Comparable can be inserted and found. |
121 |
|
*/ |
122 |
|
public void testGenericComparable() { |
123 |
+ |
int size = 120; // makes measured test run time -> 60ms |
124 |
|
ConcurrentHashMap<Object, Boolean> m = |
125 |
|
new ConcurrentHashMap<Object, Boolean>(); |
126 |
< |
for (int i = 0; i < 1000; i++) { |
126 |
> |
for (int i = 0; i < size; i++) { |
127 |
|
BI bi = new BI(i); |
128 |
|
BS bs = new BS(String.valueOf(i)); |
129 |
|
LexicographicList<BI> bis = new LexicographicList<BI>(bi); |
134 |
|
assertTrue(m.containsKey(bss)); |
135 |
|
assertTrue(m.containsKey(bis)); |
136 |
|
} |
137 |
< |
for (int i = 0; i < 1000; i++) { |
138 |
< |
assertTrue(m.containsKey(new ArrayList(Collections.singleton(new BI(i))))); |
137 |
> |
for (int i = 0; i < size; i++) { |
138 |
> |
assertTrue(m.containsKey(Collections.singletonList(new BI(i)))); |
139 |
|
} |
140 |
|
} |
141 |
|
|
145 |
|
* inserted and found. |
146 |
|
*/ |
147 |
|
public void testGenericComparable2() { |
148 |
+ |
int size = 500; // makes measured test run time -> 60ms |
149 |
|
ConcurrentHashMap<Object, Boolean> m = |
150 |
|
new ConcurrentHashMap<Object, Boolean>(); |
151 |
< |
for (int i = 0; i < 1000; i++) { |
152 |
< |
m.put(new ArrayList(Collections.singleton(new BI(i))), true); |
151 |
> |
for (int i = 0; i < size; i++) { |
152 |
> |
m.put(Collections.singletonList(new BI(i)), true); |
153 |
|
} |
154 |
|
|
155 |
< |
for (int i = 0; i < 1000; i++) { |
155 |
> |
for (int i = 0; i < size; i++) { |
156 |
|
LexicographicList<BI> bis = new LexicographicList<BI>(new BI(i)); |
157 |
|
assertTrue(m.containsKey(bis)); |
158 |
|
} |
163 |
|
* can be inserted and found. |
164 |
|
*/ |
165 |
|
public void testMixedComparable() { |
166 |
< |
int size = 10000; |
166 |
> |
int size = 1200; // makes measured test run time -> 35ms |
167 |
|
ConcurrentHashMap<Object, Object> map = |
168 |
|
new ConcurrentHashMap<Object, Object>(); |
169 |
< |
Random rng = new Random(1370014958369218000L); |
169 |
> |
Random rng = new Random(); |
170 |
|
for (int i = 0; i < size; i++) { |
171 |
|
Object x; |
172 |
|
switch (rng.nextInt(4)) { |