Skip to content

Commit 99155c0

Browse files
Merge pull request #1953 from akarnokd/OperatorSerializePerfFix
Fixed timer cast-to-int crash causing incorrect benchmark.
2 parents 7b25665 + aeea978 commit 99155c0

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/perf/java/rx/operators/OperatorSerializePerf.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,13 @@
1717

1818
import java.util.concurrent.TimeUnit;
1919

20-
import org.openjdk.jmh.annotations.BenchmarkMode;
21-
import org.openjdk.jmh.annotations.Benchmark;
22-
import org.openjdk.jmh.annotations.Mode;
23-
import org.openjdk.jmh.annotations.OutputTimeUnit;
24-
import org.openjdk.jmh.annotations.Param;
25-
import org.openjdk.jmh.annotations.Scope;
26-
import org.openjdk.jmh.annotations.State;
20+
import org.openjdk.jmh.annotations.*;
2721
import org.openjdk.jmh.infra.Blackhole;
2822

29-
import rx.Observable;
23+
import rx.*;
3024
import rx.Observable.OnSubscribe;
31-
import rx.Subscriber;
32-
import rx.jmh.InputWithIncrementingInteger;
33-
import rx.jmh.LatchedObserver;
25+
import rx.functions.Func1;
26+
import rx.jmh.*;
3427
import rx.schedulers.Schedulers;
3528

3629
@BenchmarkMode(Mode.Throughput)
@@ -81,7 +74,7 @@ public void call(Subscriber<? super Integer> s) {
8174
}
8275

8376
@State(Scope.Thread)
84-
public static class InputWithInterval extends InputWithIncrementingInteger {
77+
public static class InputWithInterval extends InputWithIncrementingInteger implements Func1<Long, Integer> {
8578

8679
@Param({ "1", "1000" })
8780
public int size;
@@ -97,7 +90,11 @@ public int getSize() {
9790
public void setup(Blackhole bh) {
9891
super.setup(bh);
9992

100-
interval = Observable.timer(0, 1, TimeUnit.MILLISECONDS).take(size).cast(Integer.class);
93+
interval = Observable.timer(0, 1, TimeUnit.MILLISECONDS).take(size).map(this);
94+
}
95+
@Override
96+
public Integer call(Long t1) {
97+
return t1.intValue();
10198
}
10299
}
103100

0 commit comments

Comments
 (0)