aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2019-04-16 16:31:47 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-04-16 16:31:47 -0700
commite0063647591ebda813559d621ac634e162107cf8 (patch)
tree809cf651183fa6a3b3d0e6ded61ce966b453d8f5
parente8343dbcb615262f408f69eaa8ea5920d641c38b (diff)
parent4d25eeab84f983c811d24b93b233af868f5112aa (diff)
downloadcaliper-e0063647591ebda813559d621ac634e162107cf8.tar.gz
Update caliper for guava 27.1
am: 4d25eeab84 Change-Id: Ib96846dbb196512b58a6fc7c58f0e007348cbff7
-rw-r--r--Android.bp8
-rw-r--r--caliper/src/main/java/com/google/caliper/json/GsonModule.java17
-rw-r--r--caliper/src/main/java/com/google/caliper/runner/ExperimentingCaliperRun.java11
-rw-r--r--caliper/src/main/java/com/google/caliper/runner/ExperimentingRunnerModule.java24
-rw-r--r--caliper/src/main/java/com/google/caliper/runner/StreamService.java8
-rw-r--r--caliper/src/main/java/com/google/caliper/worker/WorkerModule.java20
6 files changed, 53 insertions, 35 deletions
diff --git a/Android.bp b/Android.bp
index 5490ef0..2672103 100644
--- a/Android.bp
+++ b/Android.bp
@@ -34,7 +34,7 @@ java_library_host {
// Use Dagger2 annotation processor
plugins: ["dagger2-compiler"],
- java_version: "1.7",
+ java_version: "1.8",
}
// build caliper target api jar
@@ -54,7 +54,7 @@ java_library {
],
sdk_version: "core_current",
- java_version: "1.7",
+ java_version: "1.8",
}
// build caliper tests
@@ -81,7 +81,7 @@ java_test_host {
// Use Dagger2 annotation processor
plugins: ["dagger2-compiler"],
- java_version: "1.7",
+ java_version: "1.8",
}
// build caliper examples
@@ -98,7 +98,7 @@ java_library_host {
"mockito",
],
- java_version: "1.7",
+ java_version: "1.8",
}
// Build host dependencies.
diff --git a/caliper/src/main/java/com/google/caliper/json/GsonModule.java b/caliper/src/main/java/com/google/caliper/json/GsonModule.java
index 491dcca..70ba1a7 100644
--- a/caliper/src/main/java/com/google/caliper/json/GsonModule.java
+++ b/caliper/src/main/java/com/google/caliper/json/GsonModule.java
@@ -23,7 +23,7 @@ import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.bind.TypeAdapters;
import dagger.Module;
import dagger.Provides;
-import dagger.Provides.Type;
+import dagger.multibindings.IntoSet;
import org.joda.time.Instant;
import java.util.Set;
@@ -34,22 +34,26 @@ import java.util.Set;
@Module
public final class GsonModule {
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static TypeAdapterFactory provideImmutableListTypeAdapterFactory() {
return new ImmutableListTypeAdatperFactory();
}
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static TypeAdapterFactory provideImmutableMapTypeAdapterFactory() {
return new ImmutableMapTypeAdapterFactory();
}
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static TypeAdapterFactory provideNaturallySortedMapTypeAdapterFactory() {
return new NaturallySortedMapTypeAdapterFactory();
}
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static TypeAdapterFactory provideImmutableMultimapTypeAdapterFactory() {
return new ImmutableMultimapTypeAdapterFactory();
}
@@ -59,7 +63,8 @@ public final class GsonModule {
return new AnnotationExclusionStrategy();
}
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static TypeAdapterFactory provideTypeAdapterFactoryForInstant(
InstantTypeAdapter typeAdapter) {
return TypeAdapters.newFactory(Instant.class, typeAdapter);
diff --git a/caliper/src/main/java/com/google/caliper/runner/ExperimentingCaliperRun.java b/caliper/src/main/java/com/google/caliper/runner/ExperimentingCaliperRun.java
index 5214193..e57e1b0 100644
--- a/caliper/src/main/java/com/google/caliper/runner/ExperimentingCaliperRun.java
+++ b/caliper/src/main/java/com/google/caliper/runner/ExperimentingCaliperRun.java
@@ -30,7 +30,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.FutureFallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
@@ -58,9 +57,9 @@ public final class ExperimentingCaliperRun implements CaliperRun {
private static final Logger logger = Logger.getLogger(ExperimentingCaliperRun.class.getName());
- private static final FutureFallback<Object> FALLBACK_TO_NULL = new FutureFallback<Object>() {
+ private static final AsyncFunction<Throwable, Object> FALLBACK_TO_NULL = new AsyncFunction<Throwable, Object>() {
final ListenableFuture<Object> nullFuture = Futures.immediateFuture(null);
- @Override public ListenableFuture<Object> create(Throwable t) throws Exception {
+ @Override public ListenableFuture<Object> apply(Throwable t) throws Exception {
return nullFuture;
}
};
@@ -220,16 +219,16 @@ public final class ExperimentingCaliperRun implements CaliperRun {
// each of these trials can only start after all prior trials have finished, so we use
// Futures.transform to force the sequencing.
ListenableFuture<TrialResult> current =
- Futures.transform(
+ Futures.transformAsync(
previous,
new AsyncFunction<Object, TrialResult>() {
@Override public ListenableFuture<TrialResult> apply(Object ignored) {
return executor.submit(scheduledTrial.trialTask());
}
- });
+ }, MoreExecutors.directExecutor());
pendingTrials.add(current);
// ignore failure of the prior task.
- previous = Futures.withFallback(current, FALLBACK_TO_NULL);
+ previous = Futures.catchingAsync(current, Throwable.class, FALLBACK_TO_NULL, MoreExecutors.directExecutor());
}
return pendingTrials;
}
diff --git a/caliper/src/main/java/com/google/caliper/runner/ExperimentingRunnerModule.java b/caliper/src/main/java/com/google/caliper/runner/ExperimentingRunnerModule.java
index 7abcbd9..4477a61 100644
--- a/caliper/src/main/java/com/google/caliper/runner/ExperimentingRunnerModule.java
+++ b/caliper/src/main/java/com/google/caliper/runner/ExperimentingRunnerModule.java
@@ -39,7 +39,8 @@ import com.google.common.util.concurrent.Service;
import dagger.MapKey;
import dagger.Module;
import dagger.Provides;
-import dagger.Provides.Type;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.IntoSet;
import java.io.PrintWriter;
import java.lang.reflect.Method;
@@ -60,12 +61,14 @@ import javax.inject.Singleton;
final class ExperimentingRunnerModule {
private static final String RUNNER_MAX_PARALLELISM_OPTION = "runner.maxParallelism";
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static Service provideServerSocketService(ServerSocketService impl) {
return impl;
}
- @Provides(type = Type.SET)
+ @Provides
+ @IntoSet
static Service provideTrialOutputFactoryService(TrialOutputFactoryService impl) {
return impl;
}
@@ -102,13 +105,15 @@ final class ExperimentingRunnerModule {
Class<? extends ResultProcessor> value();
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@ResultProcessorClassKey(OutputFileDumper.class)
static ResultProcessor provideOutputFileDumper(OutputFileDumper impl) {
return impl;
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@ResultProcessorClassKey(HttpUploader.class)
static ResultProcessor provideHttpUploader(HttpUploader impl) {
return impl;
@@ -157,19 +162,22 @@ final class ExperimentingRunnerModule {
Class<? extends Instrument> value();
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@InstrumentClassKey(ArbitraryMeasurementInstrument.class)
static Instrument provideArbitraryMeasurementInstrument() {
return new ArbitraryMeasurementInstrument();
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@InstrumentClassKey(AllocationInstrument.class)
static Instrument provideAllocationInstrument() {
return new AllocationInstrument();
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@InstrumentClassKey(RuntimeInstrument.class)
static Instrument provideRuntimeInstrument(
@NanoTimeGranularity ShortDuration nanoTimeGranularity) {
diff --git a/caliper/src/main/java/com/google/caliper/runner/StreamService.java b/caliper/src/main/java/com/google/caliper/runner/StreamService.java
index a5852d0..4b8928a 100644
--- a/caliper/src/main/java/com/google/caliper/runner/StreamService.java
+++ b/caliper/src/main/java/com/google/caliper/runner/StreamService.java
@@ -158,11 +158,11 @@ import javax.inject.Inject;
Charset processCharset = Charset.defaultCharset();
runningReadStreams.addAndGet(2);
openStreams.addAndGet(1);
- streamExecutor.submit(
+ ListenableFuture possiblyIgnoredError1 = streamExecutor.submit(
threadRenaming("worker-stderr",
new StreamReader("stderr",
new InputStreamReader(process.getErrorStream(), processCharset))));
- streamExecutor.submit(
+ ListenableFuture possiblyIgnoredError2 = streamExecutor.submit(
threadRenaming("worker-stdout",
new StreamReader("stdout",
new InputStreamReader(process.getInputStream(), processCharset))));
@@ -176,7 +176,7 @@ import javax.inject.Inject;
socketWriter = openedSocket.writer();
runningReadStreams.addAndGet(1);
openStreams.addAndGet(1);
- streamExecutor.submit(threadRenaming("worker-socket",
+ ListenableFuture possiblyIgnoredError = streamExecutor.submit(threadRenaming("worker-socket",
new SocketStreamReader(openedSocket.reader())));
} catch (ExecutionException e) {
notifyFailed(e.getCause());
@@ -250,7 +250,7 @@ import javax.inject.Inject;
// Experimentally, even with well behaved processes there is some time between when all streams
// are closed as part of process shutdown and when the process has exited. So to not fail
// flakily when shutting down normally we need to do a timed wait
- streamExecutor.submit(new Callable<Void>() {
+ ListenableFuture possiblyIgnoredError = streamExecutor.submit(new Callable<Void>() {
@Override public Void call() throws Exception {
boolean threw = true;
try {
diff --git a/caliper/src/main/java/com/google/caliper/worker/WorkerModule.java b/caliper/src/main/java/com/google/caliper/worker/WorkerModule.java
index 1f7e201..56a5f6e 100644
--- a/caliper/src/main/java/com/google/caliper/worker/WorkerModule.java
+++ b/caliper/src/main/java/com/google/caliper/worker/WorkerModule.java
@@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableMap;
import dagger.MapKey;
import dagger.Module;
import dagger.Provides;
-import dagger.Provides.Type;
+import dagger.multibindings.IntoMap;
import java.util.Map;
import java.util.Random;
@@ -80,37 +80,43 @@ final class WorkerModule {
Class<? extends Worker> value();
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@WorkerClassKey(ArbitraryMeasurementWorker.class)
static Worker provideArbitraryMeasurementWorker(ArbitraryMeasurementWorker impl) {
return impl;
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@WorkerClassKey(MicrobenchmarkAllocationWorker.class)
static Worker provideMicrobenchmarkAllocationWorker(MicrobenchmarkAllocationWorker impl) {
return impl;
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@WorkerClassKey(MacrobenchmarkWorker.class)
static Worker provideMacrobenchmarkWorker(MacrobenchmarkWorker impl) {
return impl;
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@WorkerClassKey(MacrobenchmarkAllocationWorker.class)
static Worker provideMacrobenchmarkAllocationWorker(MacrobenchmarkAllocationWorker impl) {
return impl;
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@WorkerClassKey(RuntimeWorker.Micro.class)
static Worker provideRuntimeWorkerMicro(RuntimeWorker.Micro impl) {
return impl;
}
- @Provides(type = Type.MAP)
+ @Provides
+ @IntoMap
@WorkerClassKey(RuntimeWorker.Pico.class)
static Worker provideRuntimeWorkerPico(RuntimeWorker.Pico impl) {
return impl;