use of com.google.caliper.Benchmark in project guava by google.
the class ExecutionListBenchmark method addThenExecute_multiThreaded.
@Benchmark
int addThenExecute_multiThreaded(final int reps) throws InterruptedException {
Runnable addTask = new Runnable() {
@Override
public void run() {
for (int i = 0; i < numListeners; i++) {
list.add(listener, directExecutor());
}
}
};
int returnValue = 0;
for (int i = 0; i < reps; i++) {
list = impl.newExecutionList();
listenerLatch = new CountDownLatch(numListeners * NUM_THREADS);
for (int j = 0; j < NUM_THREADS; j++) {
executorService.submit(addTask);
}
executorService.submit(executeTask);
returnValue += (int) listenerLatch.getCount();
listenerLatch.await();
}
return returnValue;
}
use of com.google.caliper.Benchmark in project guava by google.
the class MoreExecutorsDirectExecutorBenchmark method timeUncontendedExecute.
@Benchmark
int timeUncontendedExecute(int reps) {
final Executor executor = this.executor;
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 MapBenchmark method iterateValuesAndGet.
@Benchmark
boolean iterateValuesAndGet(int reps) {
Map<Element, Element> map = mapToTest;
boolean dummy = false;
for (int i = 0; i < reps; i++) {
for (Element key : map.values()) {
// This normally wouldn't make sense, but because our keys are our values it kind of does
Element value = map.get(key);
dummy ^= key != value;
}
}
return dummy;
}
use of com.google.caliper.Benchmark in project guava by google.
the class BaseEncodingBenchmark method decodingStream.
@Benchmark
public int decodingStream(int reps) throws IOException {
int tmp = 0;
byte[] target = new byte[n];
for (int i = 0; i < reps; i++) {
StringReader source = new StringReader(decodingInputs[i & INPUTS_MASK]);
InputStream decodingStream = encoding.encoding.decodingStream(source);
decodingStream.read(target);
decodingStream.close();
tmp += target[0];
}
return tmp;
}
use of com.google.caliper.Benchmark in project guava by google.
the class BaseEncodingBenchmark method encodingStream.
@Benchmark
public int encodingStream(int reps) throws IOException {
int tmp = 0;
for (int i = 0; i < reps; i++) {
StringWriter target = new StringWriter(2 * n);
OutputStream encodingStream = encoding.encoding.encodingStream(target);
encodingStream.write(encodingInputs[i & INPUTS_MASK]);
encodingStream.close();
tmp += target.getBuffer().length();
}
return tmp;
}
Aggregations