Search in sources :

Example 1 with Footprint

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;
}
Also used : Footprint(com.google.caliper.api.Footprint) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock) Footprint(com.google.caliper.api.Footprint)

Example 2 with Footprint

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;
}
Also used : Footprint(com.google.caliper.api.Footprint) SkipThisScenarioException(com.google.caliper.api.SkipThisScenarioException) Footprint(com.google.caliper.api.Footprint)

Aggregations

Footprint (com.google.caliper.api.Footprint)2 SkipThisScenarioException (com.google.caliper.api.SkipThisScenarioException)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1