2.x: benchmark (0..1).flatMap, andThen & flattenAs performance #6017
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.
This PR adds JMH benchmarks to measure the overhead of
{Single|Maybe}.flatMap{Publisher|Observable}
,{Single|Maybe}.flattenAs{Flowable|Observable}
andCompletable.andThen({Publisher|Observable})
.Results
on i7 4770K, Windows 7 x64, Java 8u172, JMH 1.20 (larger is better):
comparing based on the final output type
Observable should be generally lower overhead yet some cases it has more overhead.
comparing what to flatten
(flatMapHide = without fusion, flatMap = reactive source, flattenAs = list source)
The hide case is expected to have the most overhead, yet the two reactive classes have uneven boosts with a supposedly fuseable cases:
comparing based on source type
Single
andMaybe
should be practically the same here, yet in some casesMaybe
is quite worse. AlsoCompletable
should effectively win over the others on each line.Plenty of optimization opportunities.