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.7 by jsr166, Wed Sep 1 07:47:27 2010 UTC vs.
Revision 1.12 by jsr166, Thu Jan 15 18:34:19 2015 UTC

# Line 1 | Line 1
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   * @test
8   * @synopsis Times and checks basic set operations
9   */
10 import java.util.*;
10   import java.io.*;
11 + import java.util.*;
12  
13   public class NavigableSetCheck {
14  
# Line 25 | Line 25 | public class NavigableSetCheck {
25      }
26  
27      public static void main(String[] args) throws Exception {
28 <        Class setClass = null;
28 >        Class<?> setClass = null;
29          int numTests = 50;
30          int size = 50000;
31  
# Line 37 | Line 37 | public class NavigableSetCheck {
37              }
38          }
39  
40
40          if (args.length > 1)
41              numTests = Integer.parseInt(args[1]);
42  
# Line 46 | Line 45 | public class NavigableSetCheck {
45  
46          System.out.println("Testing " + setClass.getName() + " trials: " + numTests + " size: " + size);
47  
49
48          absentSize = 8;
49          while (absentSize < size) absentSize <<= 1;
50          absentMask = absentSize - 1;
# Line 59 | Line 57 | public class NavigableSetCheck {
57          for (int i = 0; i < size; ++i)
58              key[i] = new Integer(i * 2 + 1);
59  
62
60          for (int rep = 0; rep < numTests; ++rep) {
61              runTest(newSet(setClass), key);
62          }
# Line 68 | Line 65 | public class NavigableSetCheck {
65  
66      }
67  
68 <    static NavigableSet newSet(Class cl) {
68 >    static NavigableSet newSet(Class<?> cl) {
69          try {
70              NavigableSet m = (NavigableSet) cl.newInstance();
71              return m;
# Line 77 | Line 74 | public class NavigableSetCheck {
74          }
75      }
76  
80
77      static void runTest(NavigableSet s, Integer[] key) {
78          shuffle(key);
79          int size = key.length;
# Line 171 | Line 167 | public class NavigableSetCheck {
167          reallyAssert(sum == expect);
168      }
169  
174
170      static void higherTest(NavigableSet s) {
171          int sum = 0;
172          int iters = s.size();
# Line 226 | Line 221 | public class NavigableSetCheck {
221          reallyAssert(sum == iters-1);
222      }
223  
229
224      static void ktest(NavigableSet s, int size, Integer[] key) {
225          timer.start("Contains               ", size);
226          int sum = 0;
# Line 237 | Line 231 | public class NavigableSetCheck {
231          reallyAssert(sum == size);
232      }
233  
240
234      static void ittest1(NavigableSet s, int size) {
235          int sum = 0;
236          timer.start("Iter Key               ", size);
# Line 268 | Line 261 | public class NavigableSetCheck {
261          rittest1(s, size);
262      }
263  
271
264      static void rtest(NavigableSet s, int size) {
265          timer.start("Remove (iterator)      ", size);
266          for (Iterator it = s.iterator(); it.hasNext(); ) {
# Line 278 | Line 270 | public class NavigableSetCheck {
270          timer.finish();
271      }
272  
281
282
273      static void dtest(NavigableSet s, int size, Integer[] key) {
274          timer.start("Add (addAll)           ", size * 2);
275          NavigableSet s2 = null;
# Line 329 | Line 319 | public class NavigableSetCheck {
319          reallyAssert(s2.isEmpty() && s.isEmpty());
320      }
321  
332
333
322      static void test(NavigableSet s, Integer[] key) {
323          int size = key.length;
324  
# Line 391 | Line 379 | public class NavigableSetCheck {
379              startTime = System.currentTimeMillis();
380          }
381  
394
382          String classify() {
383              if (name.startsWith("Contains"))
384                  return "Contains               ";
# Line 447 | Line 434 | public class NavigableSetCheck {
434  
435      static void shuffle(Integer[] keys) {
436          int size = keys.length;
437 <        for (int i=size; i>1; i--) {
437 >        for (int i = size; i > 1; i--) {
438              int r = rng.nextInt(i);
439              Integer t = keys[i-1];
440              keys[i-1] = keys[r];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines