Skip to content

Commit d429110

Browse files
Add perf tests for cache(1) variant
1 parent 20cee90 commit d429110

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

rxjava-core/src/perf/java/rx/subjects/ReplaySubjectPerf.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import java.util.concurrent.TimeUnit;
2020
import java.util.concurrent.atomic.AtomicLong;
2121

22-
import org.openjdk.jmh.annotations.BenchmarkMode;
2322
import org.openjdk.jmh.annotations.Benchmark;
23+
import org.openjdk.jmh.annotations.BenchmarkMode;
2424
import org.openjdk.jmh.annotations.Mode;
2525
import org.openjdk.jmh.annotations.OutputTimeUnit;
2626
import org.openjdk.jmh.annotations.Param;
@@ -42,8 +42,16 @@ public static class Input {
4242
}
4343

4444
@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 {
4755
final CountDownLatch latch = new CountDownLatch(1);
4856
final AtomicLong sum = new AtomicLong();
4957

@@ -71,8 +79,16 @@ public void onNext(Object o) {
7179
}
7280

7381
@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 {
7692
final CountDownLatch latch = new CountDownLatch(1);
7793
final AtomicLong sum = new AtomicLong();
7894

0 commit comments

Comments
 (0)