1313
1414package io .reactivex .rxjava4 .streamable ;
1515
16+ import java .util .List ;
1617import java .util .concurrent .TimeUnit ;
18+ import java .util .stream .Collectors ;
1719
1820import org .openjdk .jmh .annotations .*;
1921
20- import io .reactivex .rxjava4 .core .* ;
22+ import io .reactivex .rxjava4 .core .Streamable ;
2123
2224///
2325/// The map is one of the most used operator in the ecosystem so it must be fast and
6668/// StreamableSkipPerf.benchmark 100000 thrpt 5 2168,925 ┬▒ 32,591 ops/s
6769/// StreamableSkipPerf.benchmark 1000000 thrpt 5 214,055 ┬▒ 5,629 ops/s
6870/// ```
71+ ///
72+ /// # 3. sync bias via Claude Fable atomics
73+ ///
74+ /// Small regression on 1, but +200% on million vs 2., almost +410% vs baseline
75+ ///
76+ /// ```
77+ /// Benchmark (times) Mode Cnt Score Error Units
78+ /// StreamableSkipPerf.benchmark 1 thrpt 5 1392748873,097 ┬▒ 240564597,648 ops/s
79+ /// StreamableSkipPerf.benchmark 10 thrpt 5 50478482,677 ┬▒ 2503440,823 ops/s
80+ /// StreamableSkipPerf.benchmark 100 thrpt 5 8260512,961 ┬▒ 832256,445 ops/s
81+ /// StreamableSkipPerf.benchmark 1000 thrpt 5 617903,033 ┬▒ 127135,231 ops/s
82+ /// StreamableSkipPerf.benchmark 10000 thrpt 5 65116,345 ┬▒ 8425,364 ops/s
83+ /// StreamableSkipPerf.benchmark 100000 thrpt 5 6298,539 ┬▒ 739,686 ops/s
84+ /// StreamableSkipPerf.benchmark 1000000 thrpt 5 634,945 ┬▒ 99,134 ops/s
85+ /// ```
86+ ///
87+ /// # 4. indexable/enumerable/deferredenumerable
88+ ///
89+ /// ```
90+ /// Benchmark (times) Mode Cnt Score Error Units
91+ /// StreamableSkipPerf.benchmark 1 thrpt 5 1371065918,333 ┬▒ 114154178,555 ops/s
92+ /// StreamableSkipPerf.benchmark 10 thrpt 5 48387844,296 ┬▒ 1998160,368 ops/s
93+ /// StreamableSkipPerf.benchmark 100 thrpt 5 8344391,259 ┬▒ 251723,213 ops/s
94+ /// StreamableSkipPerf.benchmark 1000 thrpt 5 700332,413 ┬▒ 28667,777 ops/s
95+ /// StreamableSkipPerf.benchmark 10000 thrpt 5 68645,229 ┬▒ 3123,103 ops/s
96+ /// StreamableSkipPerf.benchmark 100000 thrpt 5 6047,152 ┬▒ 725,594 ops/s
97+ /// StreamableSkipPerf.benchmark 1000000 thrpt 5 649,134 ┬▒ 36,349 ops/s
98+ /// StreamableSkipPerf.enumerable 1 thrpt 5 71117553,552 ┬▒ 6738602,495 ops/s
99+ /// StreamableSkipPerf.enumerable 10 thrpt 5 43426136,653 ┬▒ 2744303,836 ops/s
100+ /// StreamableSkipPerf.enumerable 100 thrpt 5 2819347,969 ┬▒ 20437,839 ops/s
101+ /// StreamableSkipPerf.enumerable 1000 thrpt 5 298000,822 ┬▒ 28754,714 ops/s
102+ /// StreamableSkipPerf.enumerable 10000 thrpt 5 28839,499 ┬▒ 3096,840 ops/s
103+ /// StreamableSkipPerf.enumerable 100000 thrpt 5 2657,147 ┬▒ 23,023 ops/s
104+ /// StreamableSkipPerf.enumerable 1000000 thrpt 5 187,770 ┬▒ 42,082 ops/s
105+ /// StreamableSkipPerf.indexed 1 thrpt 5 75403131,814 ┬▒ 4676965,390 ops/s
106+ /// StreamableSkipPerf.indexed 10 thrpt 5 42730509,975 ┬▒ 6004178,786 ops/s
107+ /// StreamableSkipPerf.indexed 100 thrpt 5 3561284,547 ┬▒ 381609,301 ops/s
108+ /// StreamableSkipPerf.indexed 1000 thrpt 5 346781,462 ┬▒ 28909,008 ops/s
109+ /// StreamableSkipPerf.indexed 10000 thrpt 5 54254,177 ┬▒ 7440,753 ops/s
110+ /// StreamableSkipPerf.indexed 100000 thrpt 5 5153,256 ┬▒ 310,895 ops/s
111+ /// StreamableSkipPerf.indexed 1000000 thrpt 5 259,912 ┬▒ 76,746 ops/s
112+ /// ```
69113@ BenchmarkMode (Mode .Throughput )
70114@ Warmup (iterations = 5 , time = 1 , timeUnit = TimeUnit .SECONDS )
71115@ Measurement (iterations = 5 , time = 1 , timeUnit = TimeUnit .SECONDS )
@@ -77,14 +121,28 @@ public class StreamableSkipPerf {
77121 public int times ;
78122
79123 Streamable <Integer > result ;
124+ Streamable <List <Integer >> resultIndexed ;
125+ Streamable <List <Integer >> resultEnumerable ;
80126
81127 @ Setup
82128 public void setup () {
83129 result = Streamable .range (1 , times ).skip (times / 2 );
130+ resultIndexed = Streamable .range (1 , times ).skip (times / 2 ).collect (Collectors .toList ());
131+ resultEnumerable = Streamable .range (1 , times ).filter (_ -> true ).skip (times / 2 ).collect (Collectors .toList ());
84132 }
85133
86134 @ Benchmark
87135 public Object benchmark () {
88136 return result .blockingLast ();
89137 }
138+
139+ @ Benchmark
140+ public Object indexed () {
141+ return resultIndexed .blockingLast ();
142+ }
143+
144+ @ Benchmark
145+ public Object enumerable () {
146+ return resultEnumerable .blockingLast ();
147+ }
90148}
0 commit comments