MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

concurrent/Summing3.java:21–35  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

19 public static final long CHECK =
20 (long)SZ * ((long)SZ + 1)/2;
21 public static void main(String[] args) {
22 System.out.println(CHECK);
23 Long[] aL = new Long[SZ+1];
24 Arrays.parallelSetAll(aL, i -> (long)i);
25 Summing.timeTest("Long Array Stream Reduce",
26 CHECK, () ->
27 Arrays.stream(aL).reduce(0L, Long::sum));
28 Summing.timeTest("Long Basic Sum", CHECK, () ->
29 basicSum(aL));
30 // Destructive summation:
31 Summing.timeTest("Long parallelPrefix",CHECK, ()-> {
32 Arrays.parallelPrefix(aL, Long::sum);
33 return aL[aL.length - 1];
34 });
35 }
36}
37/* Output:
3850000005000000

Callers

nothing calls this directly

Calls 4

timeTestMethod · 0.95
basicSumMethod · 0.95
parallelSetAllMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected