19
19
import java .util .concurrent .TimeUnit ;
20
20
import java .util .concurrent .atomic .AtomicLong ;
21
21
22
- import org .openjdk .jmh .annotations .BenchmarkMode ;
23
22
import org .openjdk .jmh .annotations .Benchmark ;
23
+ import org .openjdk .jmh .annotations .BenchmarkMode ;
24
24
import org .openjdk .jmh .annotations .Mode ;
25
25
import org .openjdk .jmh .annotations .OutputTimeUnit ;
26
26
import org .openjdk .jmh .annotations .Param ;
@@ -42,8 +42,16 @@ public static class Input {
42
42
}
43
43
44
44
@ Benchmark
45
- public void subscribeBeforeEvents (final Input input , final Blackhole bh ) throws Exception {
46
- ReplaySubject <Object > subject = ReplaySubject .create ();
45
+ public void subscribeBeforeEventsUnbounded (final Input input , final Blackhole bh ) throws Exception {
46
+ subscribeBeforeEvents (ReplaySubject .create (), input , bh );
47
+ }
48
+
49
+ @ Benchmark
50
+ public void subscribeBeforeEventsCount1 (final Input input , final Blackhole bh ) throws Exception {
51
+ subscribeBeforeEvents (ReplaySubject .create (1 ), input , bh );
52
+ }
53
+
54
+ private void subscribeBeforeEvents (ReplaySubject <Object > subject , final Input input , final Blackhole bh ) throws Exception {
47
55
final CountDownLatch latch = new CountDownLatch (1 );
48
56
final AtomicLong sum = new AtomicLong ();
49
57
@@ -71,8 +79,16 @@ public void onNext(Object o) {
71
79
}
72
80
73
81
@ Benchmark
74
- public void subscribeAfterEvents (final Input input , final Blackhole bh ) throws Exception {
75
- ReplaySubject <Object > subject = ReplaySubject .create ();
82
+ public void subscribeAfterEventsUnbounded (final Input input , final Blackhole bh ) throws Exception {
83
+ subscribeAfterEvents (ReplaySubject .create (), input , bh );
84
+ }
85
+
86
+ @ Benchmark
87
+ public void subscribeAfterEventsCount1 (final Input input , final Blackhole bh ) throws Exception {
88
+ subscribeAfterEvents (ReplaySubject .create (1 ), input , bh );
89
+ }
90
+
91
+ private void subscribeAfterEvents (ReplaySubject <Object > subject , final Input input , final Blackhole bh ) throws Exception {
76
92
final CountDownLatch latch = new CountDownLatch (1 );
77
93
final AtomicLong sum = new AtomicLong ();
78
94
0 commit comments