This benchmark combines:
The goal is to test the performance of the Java Stream API before
and after the "stream fusion" optimization, and then compare the results.
Intermediate artifacts are available in this
summary.html
.
We partially reuse the benchmark suggested by
Biboudis et al.
(sources)
and used by
Møller et al.
(sources).
This is the summary of the tests performed by zulu openjdk 23.0.2, on 2025-08-11 at 05:15, on Linux with 4 CPUs, in this GHA run (the numbers are in milliseconds):
Test method | Before | After | Diff | Gain | Ratio |
---|---|---|---|---|---|
Big.loop |
45.75 |
45.72 |
-0.03 |
||
Big.stream |
171.83 |
48.02 |
-123.81 |
+72.1% |
3.58x |
Cart.loop |
31.64 |
31.66 |
+0.02 |
||
Cart.stream |
340.17 |
337.60 |
-2.57 |
||
Even.loop |
69.32 |
67.73 |
-1.59 |
||
Even.stream |
68.10 |
67.65 |
-0.44 |
||
Megamorphic.loop |
4.01 |
3.98 |
-0.04 |
||
Megamorphic.stream |
493.95 |
19.22 |
-474.73 |
+96.1% |
25.70x |
Ref.loop |
11.92 |
12.15 |
+0.23 |
||
Ref.stream |
24.68 |
15.22 |
-9.47 |
+38.3% |
1.62x |
Squares.loop |
38.51 |
38.69 |
+0.18 |
||
Squares.stream |
38.38 |
38.85 |
+0.47 |
||
Sum.loop |
36.50 |
37.45 |
+0.94 |
||
Sum.stream |
36.61 |
37.61 |
+0.99 |
The entire test took 425 seconds.
Important numbers are in the "Gain" and "Ratio" columns. Empty cells in the "Gain" column mean that the performance did not change significantly, while the "Ratio" column shows how many times the performance improved after the optimization.
Fork the repository, make your changes, and then send us
a pull request.
We will review your changes and apply them to the master
branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request, please run a full build:
make
You will need Maven 3.3+ and Java 11+ installed.