Skip to content

Commit d506ddc

Browse files
authored
2.x: Upgrade to Gradle 4.3.1, add TakeUntilPerf (#6029)
1 parent 175f7de commit d506ddc

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
dependencies {
1010
classpath "ru.vyarus:gradle-animalsniffer-plugin:1.2.0"
1111
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.13.1"
12-
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.4"
12+
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
1313
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
1414
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.2"
1515
}
@@ -201,6 +201,7 @@ jmh {
201201
jmhVersion = jmhLibVersion
202202
humanOutputFile = null
203203
includeTests = false
204+
jvmArgs = ["-Djmh.ignoreLock=true"]
204205
jvmArgsAppend = ["-Djmh.separateClasspathJAR=true"]
205206

206207
if (project.hasProperty("jmh")) {

gradle/wrapper/gradle-wrapper.jar

4 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* Copyright (c) 2016-present, RxJava Contributors.
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.*;
17+
18+
import org.openjdk.jmh.annotations.*;
19+
20+
import io.reactivex.functions.*;
21+
import io.reactivex.internal.functions.Functions;
22+
import io.reactivex.schedulers.Schedulers;
23+
24+
@BenchmarkMode(Mode.Throughput)
25+
@Warmup(iterations = 5)
26+
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
27+
@OutputTimeUnit(TimeUnit.SECONDS)
28+
@Fork(value = 1)
29+
@State(Scope.Thread)
30+
@AuxCounters
31+
public class TakeUntilPerf implements Consumer<Integer> {
32+
33+
public volatile int items;
34+
35+
static final int count = 10000;
36+
37+
Flowable<Integer> flowable;
38+
39+
Observable<Integer> observable;
40+
41+
@Override
42+
public void accept(Integer t) throws Exception {
43+
items++;
44+
}
45+
46+
@Setup
47+
public void setup() {
48+
49+
flowable = Flowable.range(1, 1000 * 1000).takeUntil(Flowable.fromCallable(new Callable<Object>() {
50+
@Override
51+
public Object call() throws Exception {
52+
int c = count;
53+
while (items < c) { }
54+
return 1;
55+
}
56+
}).subscribeOn(Schedulers.single()));
57+
58+
observable = Observable.range(1, 1000 * 1000).takeUntil(Observable.fromCallable(new Callable<Object>() {
59+
@Override
60+
public Object call() throws Exception {
61+
int c = count;
62+
while (items < c) { }
63+
return 1;
64+
}
65+
}).subscribeOn(Schedulers.single()));
66+
}
67+
68+
@Benchmark
69+
public void flowable() {
70+
final CountDownLatch cdl = new CountDownLatch(1);
71+
72+
flowable.subscribe(this, Functions.emptyConsumer(), new Action() {
73+
@Override
74+
public void run() throws Exception {
75+
cdl.countDown();
76+
}
77+
});
78+
79+
while (cdl.getCount() != 0) { }
80+
}
81+
82+
@Benchmark
83+
public void observable() {
84+
final CountDownLatch cdl = new CountDownLatch(1);
85+
86+
observable.subscribe(this, Functions.emptyConsumer(), new Action() {
87+
@Override
88+
public void run() throws Exception {
89+
cdl.countDown();
90+
}
91+
});
92+
93+
while (cdl.getCount() != 0) { }
94+
}
95+
}

0 commit comments

Comments
 (0)