Skip to content

Commit 0a0f6f7

Browse files
Fix OperatorFlatMapPerf.flatMapIntPassthruAsync Perf Test
This test was reported broken in ReactiveX#2928 (comment) Fixing by adding the use of LatchedObserver. Previously broken test results: ``` r.o.OperatorFlatMapPerf.flatMapIntPassthruAsync 1 thrpt 5 363615.622 115041.519 ops/s r.o.OperatorFlatMapPerf.flatMapIntPassthruAsync 1000 thrpt 5 350.204 125.773 ops/s r.o.OperatorFlatMapPerf.flatMapIntPassthruAsync 1000000 thrpt 5 0.319 0.184 ops/s ``` Fixed results: ``` r.o.OperatorFlatMapPerf.flatMapIntPassthruAsync 1 thrpt 5 102109.681 8709.920 ops/s r.o.OperatorFlatMapPerf.flatMapIntPassthruAsync 1000 thrpt 5 403.071 130.651 ops/s r.o.OperatorFlatMapPerf.flatMapIntPassthruAsync 1000000 thrpt 5 0.355 0.070 ops/s ```
1 parent 476ce0a commit 0a0f6f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/perf/java/rx/operators/OperatorFlatMapPerf.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import rx.Observable;
2929
import rx.functions.Func1;
3030
import rx.jmh.InputWithIncrementingInteger;
31+
import rx.jmh.LatchedObserver;
3132
import rx.schedulers.Schedulers;
3233

3334
@BenchmarkMode(Mode.Throughput)
@@ -62,14 +63,16 @@ public Observable<Integer> call(Integer i) {
6263

6364
@Benchmark
6465
public void flatMapIntPassthruAsync(Input input) throws InterruptedException {
66+
LatchedObserver<Integer> latchedObserver = input.newLatchedObserver();
6567
input.observable.flatMap(new Func1<Integer, Observable<Integer>>() {
6668

6769
@Override
6870
public Observable<Integer> call(Integer i) {
6971
return Observable.just(i).subscribeOn(Schedulers.computation());
7072
}
7173

72-
}).subscribe(input.observer);
74+
}).subscribe(latchedObserver);
75+
latchedObserver.latch.await();
7376
}
7477

7578
@Benchmark

0 commit comments

Comments
 (0)