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 File: SimpleValidationWithoutShortCircuit.java    From doov with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: MeasureFunction.java    From headlong with 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 3
Source File: ByteBufferBenchmark.java    From Oak with 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
Source File: VectorPerformance.java    From commons-geometry with Apache License 2.0 5 votes vote down vote up
/** 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
Source File: BenchmarkDemo.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
@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 6
Source File: VectorPerformance.java    From commons-geometry with Apache License 2.0 5 votes vote down vote up
/** 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 7
Source File: IntObjectHashMapBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
void put(Blackhole bh) {
    IntObjectHashMap<Long> map = new IntObjectHashMap<Long>();
    for (int key : keys) {
        bh.consume(map.put(key, VALUE));
    }
}
 
Example 8
Source File: JMHSample_28_BlackholeHelpers.java    From jmh-playground with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: BenchmarkRuleRewrite.java    From doov with 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 10
Source File: BenchmarkRuleRewrite.java    From doov with 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 11
Source File: CompressionUtilsBenchmark.java    From mantis with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: IteratorGC.java    From jmh-playground with 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));
  }
}
 
Example 13
Source File: HeadersBenchmark.java    From netty-4.1.22 with 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 14
Source File: DistkvSetBenchmark.java    From distkv with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Benchmark
public void testAsyncPutItem(Blackhole blackhole) {
  String randomStr = RandomStringUtils.random(5);
  blackhole.consume(asyncClient.sets().putItem(KEY_SET_SYNC,randomStr));
}
 
Example 15
Source File: HeadersBenchmark.java    From netty-4.1.22 with 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 16
Source File: BenchmarkRule.java    From doov with 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 File: HeadersBenchmark.java    From netty-4.1.22 with 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 18
Source File: InstantOverhead.java    From jmh-playground with 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 19
Source File: LambdaOverhead.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
public static void runAndBlackhole(Runnable runnable, Blackhole blackhole) {
  runnable.run();
  blackhole.consume(runnable);
}
 
Example 20
Source File: BLSPrimitivesBenchmark.java    From teku with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void hToG2(Blackhole bh) {
  ECP2 r = hashToG2(message);
  bh.consume(r);
}