Skip to content

Commit

Permalink
Merge pull request #1953 from akarnokd/OperatorSerializePerfFix
Browse files Browse the repository at this point in the history
Fixed timer cast-to-int crash causing incorrect benchmark.
  • Loading branch information
benjchristensen committed Dec 12, 2014
2 parents 7b25665 + aeea978 commit 99155c0
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/perf/java/rx/operators/OperatorSerializePerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@

import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;

import rx.Observable;
import rx.*;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.jmh.InputWithIncrementingInteger;
import rx.jmh.LatchedObserver;
import rx.functions.Func1;
import rx.jmh.*;
import rx.schedulers.Schedulers;

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

@State(Scope.Thread)
public static class InputWithInterval extends InputWithIncrementingInteger {
public static class InputWithInterval extends InputWithIncrementingInteger implements Func1<Long, Integer> {

@Param({ "1", "1000" })
public int size;
Expand All @@ -97,7 +90,11 @@ public int getSize() {
public void setup(Blackhole bh) {
super.setup(bh);

interval = Observable.timer(0, 1, TimeUnit.MILLISECONDS).take(size).cast(Integer.class);
interval = Observable.timer(0, 1, TimeUnit.MILLISECONDS).take(size).map(this);
}
@Override
public Integer call(Long t1) {
return t1.intValue();
}
}

Expand Down

0 comments on commit 99155c0

Please sign in to comment.