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

Comparing jsr166/src/test/loops/IntegerSum.java (file contents):
Revision 1.1 by dl, Thu Feb 28 11:41:56 2013 UTC vs.
Revision 1.3 by dl, Fri Mar 22 18:41:30 2013 UTC

# Line 36 | Line 36 | public class IntegerSum {
36          }
37      }
38  
39 <    static String sep() { return print? "\n" : " "; }
39 >    static String sep() { return print ? "\n" : " "; }
40  
41      static void allTests(int size, int trials) throws Exception {
42          System.out.println("---------------------------------------------");
# Line 74 | Line 74 | public class IntegerSum {
74          ctest(ConcurrentHashMap.<Integer>newKeySet(), vlist, vsum, size, trials);
75          ctest(new TreeSet<Integer>(), klist, ksum, size, trials);
76          ctest(new TreeSet<Integer>(), vlist, vsum, size, trials);
77 <        ctest(ConcurrentSkipListMap.<Integer>newKeySet(), klist, ksum, size, trials);
78 <        ctest(ConcurrentSkipListMap.<Integer>newKeySet(), vlist, vsum, size, trials);
77 >        ctest(new ConcurrentSkipListSet<Integer>(), klist, ksum, size, trials);
78 >        ctest(new ConcurrentSkipListSet<Integer>(), vlist, vsum, size, trials);
79  
80          mtest(new HashMap<Integer,Integer>(), keys, vals, ksum, vsum, size, trials);
81          mtest(new IdentityHashMap<Integer,Integer>(), keys, vals, ksum, vsum, size, trials);
# Line 108 | Line 108 | public class IntegerSum {
108              ctest(new PriorityBlockingQueue<Integer>(SIZE), vlist, vsum, size, trials);
109          }
110  
111 <        if (checksum.get() != 0)
112 <            throw new Error("bad computation");
111 >        if (checksum.get() != 0) throw new Error("bad computation");
112      }
113  
114 <    static void ctest(Collection<Integer> c, List<Integer> klist, int ksum, int size, int trials)
114 >    static void ctest(Collection<Integer> c, List<Integer> klist, int ksum, int size, int trials)
115          throws Exception {
116          String cn = c.getClass().getName();
117          if (cn.startsWith("java.util.concurrent."))
# Line 142 | Line 141 | public class IntegerSum {
141          long ti = itest(c, sum, trials);
142          long ts = stest(c, sum, trials);
143          long tp = ptest(c, sum, trials);
144 +        if (checksum.get() != 0) throw new Error("bad computation");
145          if (print) {
146              long scale = (long)size * trials;
147              double di = ((double)ti) / scale;
# Line 160 | Line 160 | public class IntegerSum {
160          long tlast =  System.nanoTime();
161          for (int i = 0; i < trials; ++i) {
162              Integer psum = Integer.valueOf(checksum.get());
163 <            for (Integer x : c)
163 >            for (Integer x : c)
164                  psum = SUM.apply(psum, x);
165              checksum.getAndAdd(sum - psum);
166          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines