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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations