ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/NavigableSetCheck.java
(Generate patch)

Comparing jsr166/src/test/loops/NavigableSetCheck.java (file contents):
Revision 1.2 by dl, Mon May 9 19:33:30 2005 UTC vs.
Revision 1.3 by jsr166, Thu Oct 29 23:09:07 2009 UTC

# Line 38 | Line 38 | public class NavigableSetCheck {
38          }
39  
40  
41 <        if (args.length > 1)
41 >        if (args.length > 1)
42              numTests = Integer.parseInt(args[1]);
43  
44 <        if (args.length > 2)
44 >        if (args.length > 2)
45              size = Integer.parseInt(args[2]);
46  
47          System.out.println("Testing " + setClass.getName() + " trials: " + numTests + " size: " + size);
# Line 52 | Line 52 | public class NavigableSetCheck {
52          absentMask = absentSize - 1;
53          absent = new Integer[absentSize];
54  
55 <        for (int i = 0; i < absentSize; ++i)
55 >        for (int i = 0; i < absentSize; ++i)
56              absent[i] = new Integer(i * 2);
57  
58          Integer[] key = new Integer[size];
59 <        for (int i = 0; i < size; ++i)
59 >        for (int i = 0; i < size; ++i)
60              key[i] = new Integer(i * 2 + 1);
61  
62  
# Line 95 | Line 95 | public class NavigableSetCheck {
95                  if (s.contains(key[i])) ++sum;
96              }
97          }
98 <        timer.finish();
98 >        timer.finish();
99          reallyAssert (sum == expect * iters);
100      }
101  
# Line 105 | Line 105 | public class NavigableSetCheck {
105          for (int i = 0; i < n; i++) {
106              if (s.remove(key[i])) ++sum;
107          }
108 <        timer.finish();
108 >        timer.finish();
109          reallyAssert (sum == expect);
110      }
111  
# Line 115 | Line 115 | public class NavigableSetCheck {
115          for (int i = 0; i < n; i++) {
116              if (s.add(key[i])) ++sum;
117          }
118 <        timer.finish();
118 >        timer.finish();
119          reallyAssert (sum == expect);
120      }
121  
# Line 125 | Line 125 | public class NavigableSetCheck {
125          for (int i = 0; i < n; i++) {
126              if (s.contains(key[i])) ++sum;
127          }
128 <        timer.finish();
128 >        timer.finish();
129          reallyAssert (sum == expect);
130      }
131  
# Line 135 | Line 135 | public class NavigableSetCheck {
135          for (int i = n-2; i >= 0; i-=2) {
136              if (s.remove(key[i])) ++sum;
137          }
138 <        timer.finish();
138 >        timer.finish();
139          reallyAssert (sum == expect);
140      }
141  
# Line 146 | Line 146 | public class NavigableSetCheck {
146              if (s.contains(k1[i])) ++sum;
147              if (s.contains(k2[i & absentMask])) ++sum;
148          }
149 <        timer.finish();
149 >        timer.finish();
150          reallyAssert (sum == n);
151      }
152  
# Line 157 | Line 157 | public class NavigableSetCheck {
157              if (s.contains(k1[i])) ++sum;
158              if (s.contains(k2[i & absentMask])) ++sum;
159          }
160 <        timer.finish();
160 >        timer.finish();
161          reallyAssert (sum == n);
162      }
163  
# Line 167 | Line 167 | public class NavigableSetCheck {
167          for (int i = 0; i < n; i++) {
168              if (s.contains(key[i])) ++sum;
169          }
170 <        timer.finish();
170 >        timer.finish();
171          reallyAssert (sum == expect);
172      }
173  
# Line 181 | Line 181 | public class NavigableSetCheck {
181              ++sum;
182              e = s.higher(e);
183          }
184 <        timer.finish();
184 >        timer.finish();
185          reallyAssert (sum == iters);
186      }
187  
# Line 194 | Line 194 | public class NavigableSetCheck {
194              ++sum;
195              e = s.higher(e);
196          }
197 <        timer.finish();
197 >        timer.finish();
198          reallyAssert (sum == iters);
199      }
200  
# Line 208 | Line 208 | public class NavigableSetCheck {
208              if (e != null)
209                  ++sum;
210          }
211 <        timer.finish();
211 >        timer.finish();
212          reallyAssert (sum == iters);
213      }
214  
# Line 222 | Line 222 | public class NavigableSetCheck {
222              if (e != null)
223                  ++sum;
224          }
225 <        timer.finish();
225 >        timer.finish();
226          reallyAssert (sum == iters-1);
227      }
228  
# Line 233 | Line 233 | public class NavigableSetCheck {
233          for (int i = 0; i < size; i++) {
234              if (s.contains(key[i])) ++sum;
235          }
236 <        timer.finish();
236 >        timer.finish();
237          reallyAssert (sum == size);
238      }
239  
# Line 245 | Line 245 | public class NavigableSetCheck {
245              if(it.next() != MISSING)
246                  ++sum;
247          }
248 <        timer.finish();
248 >        timer.finish();
249          reallyAssert (sum == size);
250      }
251  
# Line 260 | Line 260 | public class NavigableSetCheck {
260              if(it.next() != MISSING)
261                  ++sum;
262          }
263 <        timer.finish();
263 >        timer.finish();
264          reallyAssert (sum == size);
265      }
266  
# Line 275 | Line 275 | public class NavigableSetCheck {
275              it.next();
276              it.remove();
277          }
278 <        timer.finish();
278 >        timer.finish();
279      }
280  
281  
# Line 288 | Line 288 | public class NavigableSetCheck {
288              s2.addAll(s);
289          }
290          catch (Exception e) { e.printStackTrace(); return; }
291 <        timer.finish();
292 <    
291 >        timer.finish();
292 >
293          timer.start("Iter Equals            ", size * 2);
294          boolean eqt = s2.equals(s) && s.equals(s2);
295          reallyAssert (eqt);
296 <        timer.finish();
296 >        timer.finish();
297  
298          timer.start("Iter HashCode          ", size * 2);
299          int shc = s.hashCode();
300          int s2hc = s2.hashCode();
301          reallyAssert (shc == s2hc);
302 <        timer.finish();
302 >        timer.finish();
303  
304          timer.start("Add (present)          ", size);
305          s2.addAll(s);
306 <        timer.finish();
306 >        timer.finish();
307  
308          t6("Contains               ", size, s2, key, absent);
309  
# Line 313 | Line 313 | public class NavigableSetCheck {
313          eqt = s2.equals(s) && s.equals(s2);
314          if (as2)
315              reallyAssert (!eqt);
316 <        timer.finish();
316 >        timer.finish();
317  
318          timer.start("Iter HashCode          ", size * 2);
319          int s1h = s.hashCode();
320          int s2h = s2.hashCode();
321          if (as2)
322              reallyAssert (s1h != s2h);
323 <        timer.finish();
323 >        timer.finish();
324  
325          timer.start("Clear                  ", size);
326          s.clear();
327          s2.clear();
328 <        timer.finish();
328 >        timer.finish();
329          reallyAssert (s2.isEmpty() && s.isEmpty());
330      }
331  
332  
333 <    
333 >
334      static void test(NavigableSet s, Integer[] key) {
335          int size = key.length;
336  
# Line 368 | Line 368 | public class NavigableSetCheck {
368          private String cname;
369  
370          static final java.util.TreeMap accum = new java.util.TreeMap();
371 <    
371 >
372          static void printStats() {
373              for (Iterator it = accum.entrySet().iterator(); it.hasNext(); ) {
374                  Map.Entry e = (Map.Entry)(it.next());
375                  Stats stats = ((Stats)(e.getValue()));
376                  int n = stats.number;
377                  double t;
378 <                if (n > 0)
378 >                if (n > 0)
379                      t = stats.sum / n;
380                  else
381                      t = stats.least;
# Line 383 | Line 383 | public class NavigableSetCheck {
383                  System.out.println(e.getKey() + ": " + nano);
384              }
385          }
386 <    
386 >
387          void start(String name, long numOps) {
388              this.name = name;
389              this.cname = classify();
390              this.numOps = numOps;
391              startTime = System.currentTimeMillis();
392          }
393 <    
393 >
394  
395          String classify() {
396              if (name.startsWith("Contains"))
# Line 401 | Line 401 | public class NavigableSetCheck {
401                  return "Remove                 ";
402              else if (name.startsWith("Iter"))
403                  return "Iter                   ";
404 <            else
404 >            else
405                  return null;
406          }
407  
# Line 456 | Line 456 | public class NavigableSetCheck {
456      }
457  
458   }
459

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines