--- jsr166/src/test/loops/NavigableSetCheck.java 2005/05/09 19:33:30 1.2 +++ jsr166/src/test/loops/NavigableSetCheck.java 2009/10/29 23:09:07 1.3 @@ -38,10 +38,10 @@ public class NavigableSetCheck { } - if (args.length > 1) + if (args.length > 1) numTests = Integer.parseInt(args[1]); - if (args.length > 2) + if (args.length > 2) size = Integer.parseInt(args[2]); System.out.println("Testing " + setClass.getName() + " trials: " + numTests + " size: " + size); @@ -52,11 +52,11 @@ public class NavigableSetCheck { absentMask = absentSize - 1; absent = new Integer[absentSize]; - for (int i = 0; i < absentSize; ++i) + for (int i = 0; i < absentSize; ++i) absent[i] = new Integer(i * 2); Integer[] key = new Integer[size]; - for (int i = 0; i < size; ++i) + for (int i = 0; i < size; ++i) key[i] = new Integer(i * 2 + 1); @@ -95,7 +95,7 @@ public class NavigableSetCheck { if (s.contains(key[i])) ++sum; } } - timer.finish(); + timer.finish(); reallyAssert (sum == expect * iters); } @@ -105,7 +105,7 @@ public class NavigableSetCheck { for (int i = 0; i < n; i++) { if (s.remove(key[i])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == expect); } @@ -115,7 +115,7 @@ public class NavigableSetCheck { for (int i = 0; i < n; i++) { if (s.add(key[i])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == expect); } @@ -125,7 +125,7 @@ public class NavigableSetCheck { for (int i = 0; i < n; i++) { if (s.contains(key[i])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == expect); } @@ -135,7 +135,7 @@ public class NavigableSetCheck { for (int i = n-2; i >= 0; i-=2) { if (s.remove(key[i])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == expect); } @@ -146,7 +146,7 @@ public class NavigableSetCheck { if (s.contains(k1[i])) ++sum; if (s.contains(k2[i & absentMask])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == n); } @@ -157,7 +157,7 @@ public class NavigableSetCheck { if (s.contains(k1[i])) ++sum; if (s.contains(k2[i & absentMask])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == n); } @@ -167,7 +167,7 @@ public class NavigableSetCheck { for (int i = 0; i < n; i++) { if (s.contains(key[i])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == expect); } @@ -181,7 +181,7 @@ public class NavigableSetCheck { ++sum; e = s.higher(e); } - timer.finish(); + timer.finish(); reallyAssert (sum == iters); } @@ -194,7 +194,7 @@ public class NavigableSetCheck { ++sum; e = s.higher(e); } - timer.finish(); + timer.finish(); reallyAssert (sum == iters); } @@ -208,7 +208,7 @@ public class NavigableSetCheck { if (e != null) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == iters); } @@ -222,7 +222,7 @@ public class NavigableSetCheck { if (e != null) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == iters-1); } @@ -233,7 +233,7 @@ public class NavigableSetCheck { for (int i = 0; i < size; i++) { if (s.contains(key[i])) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == size); } @@ -245,7 +245,7 @@ public class NavigableSetCheck { if(it.next() != MISSING) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == size); } @@ -260,7 +260,7 @@ public class NavigableSetCheck { if(it.next() != MISSING) ++sum; } - timer.finish(); + timer.finish(); reallyAssert (sum == size); } @@ -275,7 +275,7 @@ public class NavigableSetCheck { it.next(); it.remove(); } - timer.finish(); + timer.finish(); } @@ -288,22 +288,22 @@ public class NavigableSetCheck { s2.addAll(s); } catch (Exception e) { e.printStackTrace(); return; } - timer.finish(); - + timer.finish(); + timer.start("Iter Equals ", size * 2); boolean eqt = s2.equals(s) && s.equals(s2); reallyAssert (eqt); - timer.finish(); + timer.finish(); timer.start("Iter HashCode ", size * 2); int shc = s.hashCode(); int s2hc = s2.hashCode(); reallyAssert (shc == s2hc); - timer.finish(); + timer.finish(); timer.start("Add (present) ", size); s2.addAll(s); - timer.finish(); + timer.finish(); t6("Contains ", size, s2, key, absent); @@ -313,24 +313,24 @@ public class NavigableSetCheck { eqt = s2.equals(s) && s.equals(s2); if (as2) reallyAssert (!eqt); - timer.finish(); + timer.finish(); timer.start("Iter HashCode ", size * 2); int s1h = s.hashCode(); int s2h = s2.hashCode(); if (as2) reallyAssert (s1h != s2h); - timer.finish(); + timer.finish(); timer.start("Clear ", size); s.clear(); s2.clear(); - timer.finish(); + timer.finish(); reallyAssert (s2.isEmpty() && s.isEmpty()); } - + static void test(NavigableSet s, Integer[] key) { int size = key.length; @@ -368,14 +368,14 @@ public class NavigableSetCheck { private String cname; static final java.util.TreeMap accum = new java.util.TreeMap(); - + static void printStats() { for (Iterator it = accum.entrySet().iterator(); it.hasNext(); ) { Map.Entry e = (Map.Entry)(it.next()); Stats stats = ((Stats)(e.getValue())); int n = stats.number; double t; - if (n > 0) + if (n > 0) t = stats.sum / n; else t = stats.least; @@ -383,14 +383,14 @@ public class NavigableSetCheck { System.out.println(e.getKey() + ": " + nano); } } - + void start(String name, long numOps) { this.name = name; this.cname = classify(); this.numOps = numOps; startTime = System.currentTimeMillis(); } - + String classify() { if (name.startsWith("Contains")) @@ -401,7 +401,7 @@ public class NavigableSetCheck { return "Remove "; else if (name.startsWith("Iter")) return "Iter "; - else + else return null; } @@ -456,4 +456,3 @@ public class NavigableSetCheck { } } -