Fix preformance issues #2
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before :
Benchmark Mode Cnt Score Error Units
LoopBenchmarkMain.forEachLambdaMaxInteger avgt 10 0,711 ± 0,159 ms/op
LoopBenchmarkMain.forEachLoopMaxInteger avgt 10 0,126 ± 0,003 ms/op
LoopBenchmarkMain.forMaxInteger avgt 10 0,233 ± 0,029 ms/op
LoopBenchmarkMain.iteratorMaxInteger avgt 10 0,127 ± 0,010 ms/op
LoopBenchmarkMain.lambdaMaxInteger avgt 10 0,620 ± 0,063 ms/op
LoopBenchmarkMain.parallelStreamMaxInteger avgt 10 0,490 ± 0,075 ms/op
LoopBenchmarkMain.streamMaxInteger avgt 10 0,673 ± 0,022 ms/op
After :
Benchmark Mode Cnt Score Error Units
LoopBenchmarkMain.forEachLambdaMaxInteger avgt 10 0,135 ± 0,031 ms/op
LoopBenchmarkMain.forEachLoopMaxInteger avgt 10 0,127 ± 0,005 ms/op
LoopBenchmarkMain.forMaxInteger avgt 10 0,229 ± 0,010 ms/op
LoopBenchmarkMain.iteratorMaxInteger avgt 10 0,123 ± 0,002 ms/op
LoopBenchmarkMain.lambdaMaxInteger avgt 10 0,104 ± 0,005 ms/op
LoopBenchmarkMain.parallelStreamMaxInteger avgt 10 0,294 ± 0,038 ms/op
LoopBenchmarkMain.streamMaxInteger avgt 10 0,116 ± 0,005 ms/op
Thread something strange on parallelStreamMaxInteger, the result is not stable. But i think the operation is to fast to take advantage of parallel, maybe you can try with 10 000 000 of integers.
PS : I think your blog post needs to be updated :)
EDIT :
By removing volatile, the result are better on forMaxInteger and parallelStreamMaxInteger :
Benchmark Mode Cnt Score Error Units
LoopBenchmarkMain.forEachLambdaMaxInteger avgt 10 0,140 ± 0,032 ms/op
LoopBenchmarkMain.forEachLoopMaxInteger avgt 10 0,125 ± 0,005 ms/op
LoopBenchmarkMain.forMaxInteger avgt 10 0,136 ± 0,065 ms/op
LoopBenchmarkMain.iteratorMaxInteger avgt 10 0,140 ± 0,022 ms/op
LoopBenchmarkMain.lambdaMaxInteger avgt 10 0,112 ± 0,002 ms/op
LoopBenchmarkMain.parallelStreamMaxInteger avgt 10 0,083 ± 0,010 ms/op
LoopBenchmarkMain.streamMaxInteger avgt 10 0,119 ± 0,010 ms/op