其實我是看了這篇文章 Parallel Streams and Spliterators1 才知道原來Internal iteration 會有small performance penalty. 但是看了數據感覺還差蠻多的...@@
- External, sequential (for-loop): 8.5 seconds
- External, parallel (ForkJoin): 2.5 second
- Internal, sequential (sequential stream): 21 seconds
- Internal, parallel (parallel stream): 6 seconds
所以需要針對效能考慮嗎? 還是反正就trade-off 用stream 寫法可以少寫一些code也少一些bug (這我也懷疑...XD)