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.2 by jsr166, Thu Feb 28 16:33:53 2013 UTC vs.
Revision 1.5 by jsr166, Wed Dec 31 17:00:58 2014 UTC

# Line 5 | Line 5
5   */
6  
7   import java.util.*;
8 import java.util.function.*;
8   import java.util.concurrent.*;
9   import java.util.concurrent.atomic.*;
10 + import java.util.function.*;
11  
12   public class IntegerSum {
13      static final int SIZE = 1000000;
# 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)
# 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 157 | Line 157 | public class IntegerSum {
157      static long itest(Collection<Integer> c, int sum, int trials) throws Exception {
158          if (c == null) throw new Error();
159          Thread.sleep(250);
160 <        long tlast =  System.nanoTime();
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)
# Line 170 | Line 170 | public class IntegerSum {
170      static long stest(Collection<Integer> c, int sum, int trials) throws Exception {
171          if (c == null) throw new Error();
172          Thread.sleep(250);
173 <        long tlast =  System.nanoTime();
173 >        long tlast = System.nanoTime();
174          for (int i = 0; i < trials; ++i) {
175              int psum = c.stream().reduce
176                  (Integer.valueOf(checksum.get()), SUM);
# Line 182 | Line 182 | public class IntegerSum {
182      static long ptest(Collection<Integer> c, int sum, int trials) throws Exception {
183          if (c == null) throw new Error();
184          Thread.sleep(250);
185 <        long tlast =  System.nanoTime();
185 >        long tlast = System.nanoTime();
186          for (int i = 0; i < trials; ++i) {
187              int psum = c.parallelStream().reduce
188                  (Integer.valueOf(checksum.get()), SUM);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines