Search in sources :

Example 1 with GetCheckedTypeValidator

use of com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator in project guava by google.

the class FuturesGetCheckedBenchmark method benchmarkGetChecked.

@Benchmark
int benchmarkGetChecked(int reps) {
    int tmp = 0;
    GetCheckedTypeValidator validator = this.validator.validator;
    Future<Object> future = this.result.future;
    Class<? extends Exception> exceptionType = this.exceptionType.exceptionType;
    for (int i = 0; i < reps; ++i) {
        try {
            tmp += getChecked(validator, future, exceptionType).hashCode();
        } catch (Exception e) {
            tmp += e.hashCode();
        }
    }
    return tmp;
}
Also used : GetCheckedTypeValidator(com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) BackingStoreException(java.util.prefs.BackingStoreException) GeneralSecurityException(java.security.GeneralSecurityException) DataFormatException(java.util.zip.DataFormatException) TooManyListenersException(java.util.TooManyListenersException) NotOwnerException(java.security.acl.NotOwnerException) IOException(java.io.IOException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) InvalidPreferencesFormatException(java.util.prefs.InvalidPreferencesFormatException) ExecutionException(java.util.concurrent.ExecutionException) FuturesGetChecked.isCheckedException(com.google.common.util.concurrent.FuturesGetChecked.isCheckedException) RefreshFailedException(javax.security.auth.RefreshFailedException) Benchmark(com.google.caliper.Benchmark)

Example 2 with GetCheckedTypeValidator

use of com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator in project guava by google.

the class FuturesGetCheckedBenchmark method addOtherEntries.

@BeforeExperiment
void addOtherEntries() throws Exception {
    GetCheckedTypeValidator validator = this.validator.validator;
    Class<? extends Exception> exceptionType = this.exceptionType.exceptionType;
    for (Class<? extends Exception> exceptionClass : OTHER_EXCEPTION_TYPES.asList().subList(0, otherEntriesInDataStructure)) {
        getChecked(validator, immediateFuture(""), exceptionClass);
    }
    for (int i = 0; i < otherEntriesInDataStructure; i++) {
        ClassValue<Boolean> classValue = new ClassValue<Boolean>() {

            @Override
            protected Boolean computeValue(Class<?> type) {
                return true;
            }
        };
        classValue.get(exceptionType);
        retainedReferencesToOtherClassValues.add(classValue);
    }
}
Also used : GetCheckedTypeValidator(com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator) BeforeExperiment(com.google.caliper.BeforeExperiment)

Aggregations

GetCheckedTypeValidator (com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator)2 BeforeExperiment (com.google.caliper.BeforeExperiment)1 Benchmark (com.google.caliper.Benchmark)1 FuturesGetChecked.isCheckedException (com.google.common.util.concurrent.FuturesGetChecked.isCheckedException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 NotOwnerException (java.security.acl.NotOwnerException)1 TooManyListenersException (java.util.TooManyListenersException)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 BackingStoreException (java.util.prefs.BackingStoreException)1 InvalidPreferencesFormatException (java.util.prefs.InvalidPreferencesFormatException)1 DataFormatException (java.util.zip.DataFormatException)1 RefreshFailedException (javax.security.auth.RefreshFailedException)1