From 0a0f6f7a900a39d8ec86faa783a9dd85c713458d Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Thu, 18 Jun 2015 11:35:35 -0700 Subject: [PATCH] Fix OperatorFlatMapPerf.flatMapIntPassthruAsync Perf Test This test was reported broken in https://github.com/ReactiveX/RxJava/pull/2928#issuecomment-113229698 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 ``` --- src/perf/java/rx/operators/OperatorFlatMapPerf.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/perf/java/rx/operators/OperatorFlatMapPerf.java b/src/perf/java/rx/operators/OperatorFlatMapPerf.java index 6739fb0a1d..c20cff67f1 100644 --- a/src/perf/java/rx/operators/OperatorFlatMapPerf.java +++ b/src/perf/java/rx/operators/OperatorFlatMapPerf.java @@ -28,6 +28,7 @@ import rx.Observable; import rx.functions.Func1; import rx.jmh.InputWithIncrementingInteger; +import rx.jmh.LatchedObserver; import rx.schedulers.Schedulers; @BenchmarkMode(Mode.Throughput) @@ -62,6 +63,7 @@ public Observable call(Integer i) { @Benchmark public void flatMapIntPassthruAsync(Input input) throws InterruptedException { + LatchedObserver latchedObserver = input.newLatchedObserver(); input.observable.flatMap(new Func1>() { @Override @@ -69,7 +71,8 @@ public Observable call(Integer i) { return Observable.just(i).subscribeOn(Schedulers.computation()); } - }).subscribe(input.observer); + }).subscribe(latchedObserver); + latchedObserver.latch.await(); } @Benchmark