diff options
author | Colin Cross <ccross@android.com> | 2019-04-15 21:31:03 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-04-15 21:31:03 -0700 |
commit | d1d394bdc80b10c66878ae0c71b7d05a334168bc (patch) | |
tree | 809cf651183fa6a3b3d0e6ded61ce966b453d8f5 | |
parent | fed431afe2537c1d6c4930d58fe71ff0ca084c0b (diff) | |
parent | 5224dab50f25dfcd18c4a2f448e84ca7d1ae6574 (diff) | |
download | caliper-d1d394bdc80b10c66878ae0c71b7d05a334168bc.tar.gz |
Update caliper for guava 27.1
am: 5224dab50f
Change-Id: Ia88fdff5d5a436ddb6fa4f9a0ca72e9eb6545574
6 files changed, 53 insertions, 35 deletions
@@ -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; |