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; |
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) |
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); |
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); |