Java Code Examples for org.openjdk.jmh.infra.Blackhole#consume()

The following examples show how to use org.openjdk.jmh.infra.Blackhole#consume() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: headlong   File: MeasureFunction.java    License: Apache License 2.0 6 votes vote down vote up
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 1)
public void init_with_wrapped_bouncy_keccak(Blackhole blackhole) {
    blackhole.consume(Function.parse("sam(bytes,bool,uint256[])", new WrappedKeccak(256)));
}
 
Example 2
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1)
@Threads(50)
@Warmup(iterations = 5)
@Measurement(iterations = 5)
public void testSimpleBeanValidation(ValidationState state, Blackhole blackHole) {
    BenchmarkSetup benchmarkSetup = new BenchmarkSetup(BenchmarkModelWrapper::new, state);
    Result result = state.rule.executeOn(benchmarkSetup.model);
    assertThat(getActualViolationCount(result)).isEqualTo(benchmarkSetup.expectedViolationCount);
    blackHole.consume(result);
}
 
Example 3
Source Project: Oak   File: ByteBufferBenchmark.java    License: Apache License 2.0 5 votes vote down vote up
@Warmup(iterations = 1)
@Measurement(iterations = 10)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1)
@Threads(1)
@Benchmark
public void get(Blackhole blackhole, BenchmarkState state) {
    for (int i=0; i < state.bytes; ++i) {
        blackhole.consume(state.byteBuffer.get(i));
    }
}
 
Example 4
/** Run a benchmark test on a function that produces a vector.
 * @param <V> Vector implementation type
 * @param input vector input
 * @param bh jmh blackhole for consuming output
 * @param fn function to call
 */
private static <V extends Vector<V>> void testUnary(final VectorInputBase<V> input, final Blackhole bh,
        final UnaryOperator<V> fn) {
    for (final V vec : input.getVectors()) {
        bh.consume(fn.apply(vec));
    }
}
 
Example 5
@Setup
public void setup(final Blackhole bh) {
    workerBaseline = new Worker() {
        double x;

        @Override
        public void work() {
            // do nothing
        }
    };

    workerWrong = new Worker() {
        double x;

        @Override
        public void work() {
            Math.log(x);
        }
    };

    workerRight = new Worker() {
        double x;

        @Override
        public void work() {
            bh.consume(Math.log(x));
        }
    };

}
 
Example 6
@Benchmark
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 50, time = 3, timeUnit = TimeUnit.SECONDS)
@Threads(1)
public void testSnappyDeCompress(Blackhole blackhole, MyState state) throws IOException {
    blackhole.consume(CompressionUtils.decompressAndBase64Decode(state.snappyCompressed, true, true));
}
 
Example 7
Source Project: doov   File: BenchmarkRuleRewrite.java    License: Apache License 2.0 5 votes vote down vote up
@Benchmark
public void test_account_4_short_circuit(Blackhole blackhole) {
    boolean valid = benchRule4.executeOn(sample).value();
    if (blackhole != null) {
        blackhole.consume(valid);
    }
}
 
Example 8
Source Project: doov   File: BenchmarkRuleRewrite.java    License: Apache License 2.0 5 votes vote down vote up
@Benchmark
public void test_account_3_short_circuit(Blackhole blackhole) {
    boolean valid = benchRule3.executeOn(sample).value();
    if (blackhole != null) {
        blackhole.consume(valid);
    }
}
 
Example 9
@Override
void put(Blackhole bh) {
    IntObjectHashMap<Long> map = new IntObjectHashMap<Long>();
    for (int key : keys) {
        bh.consume(map.put(key, VALUE));
    }
}
 
Example 10
/** Run a benchmark test on a function that produces a double.
 * @param <V> Vector implementation type
 * @param input vector input
 * @param bh jmh blackhole for consuming output
 * @param fn function to call
 */
private static <V extends Vector<V>> void testToDouble(final VectorInputBase<V> input, final Blackhole bh,
        final ToDoubleFunction<V> fn) {
    for (final V vec : input.getVectors()) {
        bh.consume(fn.applyAsDouble(vec));
    }
}
 
Example 11
@Benchmark
@BenchmarkMode(Mode.All)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void testTheMethod5(TestState state, Blackhole blackhole) {
    SomeClass someClass = new SomeClass();
    blackhole.consume(someClass.oneMethod(state.m, state.s));
}
 
Example 12
Source Project: teku   File: BLSPrimitivesBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void hToG2(Blackhole bh) {
  ECP2 r = hashToG2(message);
  bh.consume(r);
}
 
Example 13
Source Project: jmh-playground   File: LambdaOverhead.java    License: Apache License 2.0 4 votes vote down vote up
public static void runAndBlackhole(Runnable runnable, Blackhole blackhole) {
  runnable.run();
  blackhole.consume(runnable);
}
 
Example 14
Source Project: jmh-playground   File: InstantOverhead.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void withClock(Blackhole blackhole) throws InterruptedException {
  Instant start = clock.instant();
  Thread.sleep(2);
  blackhole.consume(Duration.between(start, clock.instant()).toMillis());
}
 
Example 15
Source Project: netty-4.1.22   File: HeadersBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public void httpAddAllFast(Blackhole bh) {
    bh.consume(emptyHttpHeaders.add(httpHeaders));
}
 
Example 16
Source Project: doov   File: BenchmarkRule.java    License: Apache License 2.0 4 votes vote down vote up
public void valid_country_100(Blackhole blackhole) {
    boolean valid = ACCOUNT_VALID_COUNTRY_100.executeOn(MODEL).value();
    if (blackhole != null) {
        blackhole.consume(valid);
    }
}
 
Example 17
Source Project: netty-4.1.22   File: HeadersBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public void httpAddAllFastest(Blackhole bh) {
    bh.consume(emptyHttpHeadersNoValidate.add(httpHeaders));
}
 
Example 18
@Benchmark
public void testAsyncPutItem(Blackhole blackhole) {
  String randomStr = RandomStringUtils.random(5);
  blackhole.consume(asyncClient.sets().putItem(KEY_SET_SYNC,randomStr));
}
 
Example 19
Source Project: netty-4.1.22   File: HeadersBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public void http2AddAllFastest(Blackhole bh) {
    bh.consume(emptyHttp2HeadersNoValidate.add(http2Headers));
}
 
Example 20
Source Project: jmh-playground   File: IteratorGC.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void rawForLoop(Blackhole blackhole) {
  for (int i = 0; i < strings.size(); i++) {
    blackhole.consume(strings.get(i));
  }
}