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

Comparing jsr166/src/test/loops/NavigableMapCheck.java (file contents):
Revision 1.9 by jsr166, Wed Sep 1 07:47:27 2010 UTC vs.
Revision 1.14 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 map operations
9   */
10 import java.util.*;
10   import java.io.*;
11 + import java.util.*;
12  
13   public class NavigableMapCheck {
14  
# Line 25 | Line 25 | public class NavigableMapCheck {
25      }
26  
27      public static void main(String[] args) throws Exception {
28 <        Class mapClass = null;
28 >        Class<?> mapClass = null;
29          int numTests = 50;
30          int size = 50000;
31  
# Line 37 | Line 37 | public class NavigableMapCheck {
37              }
38          }
39  
40
40          if (args.length > 1)
41              numTests = Integer.parseInt(args[1]);
42  
# Line 46 | Line 45 | public class NavigableMapCheck {
45  
46          System.out.println("Testing " + mapClass.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 NavigableMapCheck {
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(newMap(mapClass), key);
62          }
# Line 68 | Line 65 | public class NavigableMapCheck {
65  
66      }
67  
68 <    static NavigableMap newMap(Class cl) {
68 >    static NavigableMap newMap(Class<?> cl) {
69          try {
70              NavigableMap m = (NavigableMap) cl.newInstance();
71              return m;
# Line 77 | Line 74 | public class NavigableMapCheck {
74          }
75      }
76  
80
77      static void runTest(NavigableMap s, Integer[] key) {
78          shuffle(key);
79          int size = key.length;
# Line 171 | Line 167 | public class NavigableMapCheck {
167          reallyAssert(sum == expect);
168      }
169  
174
170      static void t9(NavigableMap s) {
171          int sum = 0;
172          int iters = 20;
# Line 237 | Line 232 | public class NavigableMapCheck {
232          reallyAssert(sum == iters-1);
233      }
234  
240
235      static void ktest(NavigableMap s, int size, Integer[] key) {
236          timer.start("ContainsKey            ", size);
237          Set ks = s.keySet();
# Line 249 | Line 243 | public class NavigableMapCheck {
243          reallyAssert(sum == size);
244      }
245  
252
246      static void ittest1(NavigableMap s, int size) {
247          int sum = 0;
248          timer.start("Iter Key               ", size);
# Line 299 | Line 292 | public class NavigableMapCheck {
292          reallyAssert(sum == size);
293      }
294  
302
295      static void rittest(NavigableMap s, int size) {
296          rittest1(s, size);
297          //        rittest2(s, size);
298      }
299  
308
300      static void rtest(NavigableMap s, int size) {
301          timer.start("Remove (iterator)      ", size);
302          for (Iterator it = s.keySet().iterator(); it.hasNext(); ) {
# Line 324 | Line 315 | public class NavigableMapCheck {
315          timer.finish();
316      }
317  
327
318      static void dtest(NavigableMap s, int size, Integer[] key) {
319          timer.start("Put (putAll)           ", size * 2);
320          NavigableMap s2 = null;
# Line 391 | Line 381 | public class NavigableMapCheck {
381          reallyAssert(s2.isEmpty() && s.isEmpty());
382      }
383  
394
395
384      static void test(NavigableMap s, Integer[] key) {
385          int size = key.length;
386  
# Line 454 | Line 442 | public class NavigableMapCheck {
442              startTime = System.currentTimeMillis();
443          }
444  
457
445          String classify() {
446              if (name.startsWith("Get"))
447                  return "Get                    ";
# Line 510 | Line 497 | public class NavigableMapCheck {
497  
498      static void shuffle(Integer[] keys) {
499          int size = keys.length;
500 <        for (int i=size; i>1; i--) {
500 >        for (int i = size; i > 1; i--) {
501              int r = rng.nextInt(i);
502              Integer t = keys[i-1];
503              keys[i-1] = keys[r];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines