File tree Expand file tree Collapse file tree 2 files changed +2
-2
lines changed
src/main/java/lambdasinaction/chap6 Expand file tree Collapse file tree 2 files changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class ParallelStreams {
6
6
7
7
public static long iterativeSum (long n ) {
8
8
long result = 0 ;
9
- for (long i = 0 ; i < n ; i ++) {
9
+ for (long i = 0 ; i <= n ; i ++) {
10
10
result += i ;
11
11
}
12
12
return result ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ public class ParallelStreamsHarness {
8
8
public static final ForkJoinPool FORK_JOIN_POOL = new ForkJoinPool ();
9
9
10
10
public static void main (String [] args ) {
11
- System .out .println ("Iterative Sum done in: " + measurePerf (ParallelStreams ::sequentialSum , 10_000_000L ) + " msecs" );
11
+ System .out .println ("Iterative Sum done in: " + measurePerf (ParallelStreams ::iterativeSum , 10_000_000L ) + " msecs" );
12
12
System .out .println ("Sequential Sum done in: " + measurePerf (ParallelStreams ::sequentialSum , 10_000_000L ) + " msecs" );
13
13
System .out .println ("Parallel forkJoinSum done in: " + measurePerf (ParallelStreams ::parallelSum , 10_000_000L ) + " msecs" );
14
14
System .out .println ("Range forkJoinSum done in: " + measurePerf (ParallelStreams ::rangedSum , 10_000_000L ) + " msecs" );
You can’t perform that action at this time.
0 commit comments