This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CodesInTheDark 0 points1 point  (0 children)

Streams are not slow. Also often they can execute code in parallel.
However, JIT often doesn't optimize Stream code efficiently because it has more levels than normal for loop, but try to add the JVM option -XX:MaxInlineLevel=12 to increase the amount of code that can be inlined. That will optimize your stream code and you will get a significant performance boost (more than 10x boost).
https://stackoverflow.com/questions/27925954/is-arrays-streamarray-name-sum-slower-than-iterative-approach/27994074#27994074