Skip to content

Commit 9657f50

Browse files
committed
Merge pull request #3353 from akarnokd/RangePerf2x
2.x: range perf + added missing header.
2 parents 1e36ad4 + 8f93927 commit 9657f50

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

src/perf/java/io/reactivex/InputWithIncrementingInteger.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Copyright 2015 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
114
package io.reactivex;
215

316
import java.util.Iterator;

src/perf/java/io/reactivex/LatchedObserver.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Copyright 2015 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
114
package io.reactivex;
215

316
import java.util.concurrent.CountDownLatch;

src/perf/java/io/reactivex/OperatorFlatMapPerf.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Copyright 2015 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
114
package io.reactivex;
215

316
import java.util.concurrent.TimeUnit;

src/perf/java/io/reactivex/OperatorMergePerf.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Copyright 2015 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
114
package io.reactivex;
215

316
import java.util.*;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* Copyright 2015 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package io.reactivex;
15+
16+
import java.util.concurrent.TimeUnit;
17+
18+
import org.openjdk.jmh.annotations.*;
19+
import org.openjdk.jmh.infra.Blackhole;
20+
21+
import io.reactivex.internal.schedulers.SingleScheduler;
22+
import io.reactivex.schedulers.Schedulers;
23+
24+
@BenchmarkMode(Mode.Throughput)
25+
@Warmup(iterations = 5)
26+
@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
27+
@OutputTimeUnit(TimeUnit.SECONDS)
28+
@Fork(value = 1)
29+
@State(Scope.Thread)
30+
public class RangePerf {
31+
@Param({ "1", "1000", "1000000" })
32+
public int times;
33+
34+
Observable<Integer> range;
35+
36+
Observable<Integer> rangeAsync;
37+
38+
Observable<Integer> rangeAsyncPipeline;
39+
40+
@Setup
41+
public void setup() {
42+
range = Observable.range(1, times);
43+
44+
rangeAsync = range.observeOn(Schedulers.single());
45+
46+
rangeAsyncPipeline = range.subscribeOn(new SingleScheduler()).observeOn(Schedulers.single());
47+
}
48+
49+
@Benchmark
50+
public Object rangeSync(Blackhole bh) {
51+
LatchedObserver<Integer> lo = new LatchedObserver<>(bh);
52+
53+
range.subscribe(lo);
54+
55+
return lo;
56+
}
57+
58+
@Benchmark
59+
public void rangeAsync(Blackhole bh) throws Exception {
60+
LatchedObserver<Integer> lo = new LatchedObserver<>(bh);
61+
62+
rangeAsync.subscribe(lo);
63+
64+
lo.latch.await();
65+
}
66+
67+
@Benchmark
68+
public void rangePipeline(Blackhole bh) throws Exception {
69+
LatchedObserver<Integer> lo = new LatchedObserver<>(bh);
70+
71+
rangeAsyncPipeline.subscribe(lo);
72+
73+
lo.latch.await();
74+
}
75+
76+
}

0 commit comments

Comments
 (0)