@Benchmark @Group("pingpong") public void pong(Control cnt) { while (!cnt.stopMeasurement && !flag.compareAndSet(true, false)) { // this body is intentionally left blank } } }
@Benchmark @Group("pingpong") public void ping(Control cnt) { while (!cnt.stopMeasurement && !flag.compareAndSet(false, true)) { // this body is intentionally left blank } }
@Benchmark @Group("rw") public boolean randomGet(ThreadState state) { String key = testData[state.next() & (testData.length - 1)]; return set.contains(key); } }
@Benchmark @Group("rw") public boolean randomContainsAddRemove(ThreadState state) { String key = testData[state.next() & (testData.length - 1)]; int x = state.next() & ((1 << 20) - 1); if (x < containsRatio) { return set.contains(key); } else if (x < addRatio) { return set.add(key); } else { return set.remove(key); } }
@Benchmark @Group("rw") public long get() { return counter.get(); } }
@Benchmark @Group("rw") public void inc() { counter.inc(); }
@Benchmark @Group("tpt") public void offer(OfferCounters counters) { if (!q.relaxedOffer(ONE)) { counters.offersFailed++; } else { counters.offersMade++; } }
@Benchmark @Group("backoffOneNano") @GroupThreads(1) public void read(Control cnt) { while (!consumer.read() && !cnt.stopMeasurement) { LockSupport.parkNanos(1L); } } }
@Benchmark @Group("tpt") public void offer(OfferCounters counters) { if (!q.offer(element)) { counters.offersFailed++; backoff(); } else { counters.offersMade++; } if (DELAY_PRODUCER != 0) { Blackhole.consumeCPU(DELAY_PRODUCER); } }
@Benchmark @Group("twoMixedLengthPrimitiveArgs") @GroupThreads(CONSUMER_THREADS) public int twoMixedLengthPrimitiveArgsProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
@Benchmark @Group("noArgs") @GroupThreads(CONSUMER_THREADS) public int noArgsProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
@Benchmark @Group("ring") @GroupThreads(1) public void ping(Control ctl, Source s) { s.ping(ctl); }
@Benchmark @Group("onePrimitiveArg") @GroupThreads(CONSUMER_THREADS) public int onePrimitiveArgProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
@Benchmark @Group("busy") @GroupThreads(1) public void readBusy(Control cnt) { while (!consumer.read() && !cnt.stopMeasurement) { } }
@Benchmark @Group("tpt") public void poll(PollCounters counters, ConsumerMarker cm, Blackhole bh) { Integer e = q.relaxedPoll(); if (e == null) { counters.pollsFailed++; } else { bh.consume(e); counters.pollsMade++; } }
@Benchmark @Group("oneObjectArg") @GroupThreads(CONSUMER_THREADS) public int oneObjectArgProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
@Benchmark @Group("oneReferenceArg") @GroupThreads(CONSUMER_THREADS) public int oneReferenceArgProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
@Benchmark @Group("tenMixedArgs") @GroupThreads(CONSUMER_THREADS) public int tenMixedArgsProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
@Benchmark @Group("alignedPrimitiveArgs") @GroupThreads(CONSUMER_THREADS) public int alignedPrimitiveArgsProcessor(final ProcessorCounters counters) { return doProcess(mpscChannel, counters); }
/** * @param ctl required here to make the benchmark generate code correctly(JMH 0.2 issue, fixed on main) */ @Benchmark @Group("ring") @GroupThreads(1) public void loop(Control ctl, Link l) { l.link(); } }