Search in sources :

Example 1 with Benchmark

use of com.google.caliper.Benchmark in project guava by google.

the class ExecutionListBenchmark method executeThenAdd_singleThreaded.

@Benchmark
int executeThenAdd_singleThreaded(int reps) {
    int returnValue = 0;
    for (int i = 0; i < reps; i++) {
        list = impl.newExecutionList();
        list.execute();
        listenerLatch = new CountDownLatch(numListeners);
        for (int j = 0; j < numListeners; j++) {
            list.add(listener, directExecutor());
            returnValue += listenerLatch.getCount();
        }
        returnValue += listenerLatch.getCount();
    }
    return returnValue;
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Footprint(com.google.caliper.api.Footprint) Benchmark(com.google.caliper.Benchmark)

Example 2 with Benchmark

use of com.google.caliper.Benchmark 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 3 with Benchmark

use of com.google.caliper.Benchmark in project guava by google.

the class MoreExecutorsDirectExecutorBenchmark method timeContendedExecute.

@Benchmark
int timeContendedExecute(int reps) {
    final Executor executor = this.executor;
    for (Thread thread : threads) {
        if (!thread.isAlive()) {
            thread.start();
        }
    }
    final CountingRunnable countingRunnable = this.countingRunnable;
    for (int i = 0; i < reps; i++) {
        executor.execute(countingRunnable);
    }
    return countingRunnable.integer.get();
}
Also used : Executor(java.util.concurrent.Executor) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) Footprint(com.google.caliper.api.Footprint) Benchmark(com.google.caliper.Benchmark)

Example 4 with Benchmark

use of com.google.caliper.Benchmark in project guava by google.

the class StripedBenchmark method timeConstruct.

@Benchmark
long timeConstruct(long reps) {
    long rvalue = 0;
    int numStripesLocal = numStripes;
    Impl implLocal = impl;
    for (long i = 0; i < reps; i++) {
        rvalue += implLocal.get(numStripesLocal).hashCode();
    }
    return rvalue;
}
Also used : Footprint(com.google.caliper.api.Footprint) Benchmark(com.google.caliper.Benchmark)

Example 5 with Benchmark

use of com.google.caliper.Benchmark in project guava by google.

the class StripedBenchmark method timeGetAt.

@Benchmark
long timeGetAt(long reps) {
    long rvalue = 0;
    int[] stripesLocal = stripes;
    int mask = numStripes - 1;
    Striped<Lock> stripedLocal = striped;
    for (long i = 0; i < reps; i++) {
        rvalue += stripedLocal.getAt(stripesLocal[(int) (i & mask)]).hashCode();
    }
    return rvalue;
}
Also used : Footprint(com.google.caliper.api.Footprint) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock) Benchmark(com.google.caliper.Benchmark)

Aggregations

Benchmark (com.google.caliper.Benchmark)15 Footprint (com.google.caliper.api.Footprint)8 CountDownLatch (java.util.concurrent.CountDownLatch)4 Element (com.google.common.collect.CollectionBenchmarkSampleData.Element)2 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)2 Executor (java.util.concurrent.Executor)2 GetCheckedTypeValidator (com.google.common.util.concurrent.FuturesGetChecked.GetCheckedTypeValidator)1 FuturesGetChecked.isCheckedException (com.google.common.util.concurrent.FuturesGetChecked.isCheckedException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)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