use of com.google.caliper.api.Footprint in project guava by google.
the class StripedBenchmark method sizeOfPopulatedStriped.
@Footprint
Object sizeOfPopulatedStriped() {
locks.clear();
Striped<Lock> striped = impl.get(numStripes);
for (int i : stripes) {
locks.add(striped.getAt(i));
}
return striped;
}
use of com.google.caliper.api.Footprint in project guava by google.
the class AbstractFutureFootprintBenchmark method measureSize.
// This exclusion doesn't exclude the TOMBSTONE objects we set. So 'done' NEW futures will look
// larger than they are.
@SuppressWarnings("FutureReturnValueIgnored")
@Footprint(exclude = { Runnable.class, Executor.class, Thread.class, Exception.class })
public Object measureSize() {
for (Thread thread : blockedThreads) {
thread.interrupt();
}
blockedThreads.clear();
final Facade<Object> f = impl.newFacade();
for (int i = 0; i < numThreads; i++) {
Thread thread = new Thread() {
@Override
public void run() {
try {
f.get();
} catch (Throwable expected) {
}
}
};
thread.start();
blockedThreads.add(thread);
}
for (int i = 0; i < numListeners; i++) {
f.addListener(Runnables.doNothing(), directExecutor());
}
for (Thread thread : blockedThreads) {
AbstractFutureBenchmarks.awaitWaiting(thread);
}
switch(state) {
case NOT_DONE:
break;
case FINISHED:
f.set(null);
break;
case CANCELLED:
f.cancel(false);
break;
case FAILED:
f.setException(new Exception());
break;
default:
throw new AssertionError();
}
return f;
}
Aggregations