@Benchmark @Group("trackDelayed") public void trackWithDelayedAcks(Control control, TrackerState trackerState) throws Exception { if (!control.stopMeasurement) { final AcknowledgableWatermark wmark = new AcknowledgableWatermark(new DefaultCheckpointableWatermark( "0", new LongWatermark(trackerState._index))); trackerState._watermarkTracker.track(wmark); trackerState._index++; int delay = trackerState._random.nextInt(10); trackerState._executorService.schedule(new Runnable() { @Override public void run() { wmark.ack(); } }, delay, TimeUnit.MILLISECONDS); } }
@Benchmark @Group("scheduledDelayed") public void scheduledDelayedAcks(Control control, TrackerState trackerState) throws Exception { if (!control.stopMeasurement) { final AcknowledgableWatermark wmark = new AcknowledgableWatermark(new DefaultCheckpointableWatermark( "0", new LongWatermark(trackerState._index))); trackerState._index++; int delay = trackerState._random.nextInt(10); trackerState._executorService.schedule(new Runnable() { @Override public void run() { wmark.ack(); } }, delay, TimeUnit.MILLISECONDS); } }
@Benchmark @Group("scheduledNoRandom") public void scheduledNoRandomDelayedAcks(Control control, TrackerState trackerState) throws Exception { if (!control.stopMeasurement) { final AcknowledgableWatermark wmark = new AcknowledgableWatermark(new DefaultCheckpointableWatermark( "0", new LongWatermark(trackerState._index))); trackerState._index++; int delay = 10; trackerState._executorService.schedule(new Runnable() { @Override public void run() { wmark.ack(); } }, delay, TimeUnit.MILLISECONDS); } }
@Benchmark() @Group("form_init") public void recForm() throws Exception { MockApp mockApp = new MockApp("/app_performance/"); MockSessionNavigationResponder mockSessionNavigationResponder = new MockSessionNavigationResponder(mockApp.getSession()); SessionNavigator sessionNavigator = new SessionNavigator(mockSessionNavigationResponder); SessionWrapper session = mockApp.getSession(); sessionNavigator.startNextSessionStep(); session.setCommand("m1"); sessionNavigator.startNextSessionStep(); session.setDatum("case_id", "3b6bff05-b9c3-42d8-9b12-9b27a834d330"); sessionNavigator.startNextSessionStep(); session.setCommand("m1-f2"); sessionNavigator.startNextSessionStep(); session.setDatum("case_id_new_imci_visit_0", "593ef28a-34ff-421d-a29c-6a0fd975df95"); sessionNavigator.startNextSessionStep(); FormEntryController fec = mockApp.loadAndInitForm("large_tdh_form.xml"); fec.getModel().getEvent(); }
@Benchmark @Group("pingpong") public void ping(Control cnt) { while (!cnt.stopMeasurement && !flag.compareAndSet(false, true)) { // this body is intentionally left blank } }
@Benchmark @Group("pingpong") public void pong(Control cnt) { while (!cnt.stopMeasurement && !flag.compareAndSet(true, false)) { // this body is intentionally left blank } }
@Benchmark @Group("no_contention") @GroupThreads(1) public void no_contention_drain(DrainCounters counters, ConsumerMarker cm) { q.drainTo(next -> { counters.drained++; next.deferred.resolve(null); return true; }); }
@Benchmark @Group("mild_contention") @GroupThreads(1) public void mild_contention_drain(DrainCounters counters, ConsumerMarker cm) { q.drainTo(next -> { counters.drained++; next.deferred.resolve(null); return true; }); }
@Benchmark @Group("high_contention") @GroupThreads(1) public void high_contention_drain(DrainCounters counters, ConsumerMarker cm) { q.drainTo(next -> { counters.drained++; next.deferred.resolve(null); return true; }); }
@Benchmark @Group("g") @GroupThreads(3) public void writing() { concurrentLinkedQueue.offer("test"); }
@Benchmark @Group("g") @GroupThreads(1) public void reading() { concurrentLinkedQueue.poll(); }
@Benchmark @Group("no_contention") @GroupThreads(1) public void no_contention_offer(OfferCounters counters) { if (q.offer(ONE, 1)) { counters.offersMade++; } else { counters.offersFailed++; } }
@Benchmark @Group("no_contention") @GroupThreads(1) public void no_contention_drain(DrainCounters counters, ConsumerMarker cm) { q.drainTo((s, b) -> { counters.drained++; return true; }, 1000); }
@Benchmark @Group("mild_contention") @GroupThreads(2) public void mild_contention_offer(OfferCounters counters) { if (q.offer(ONE, 1)) { counters.offersMade++; } else { counters.offersFailed++; } }
@Benchmark @Group("mild_contention") @GroupThreads(1) public void mild_contention_drain(DrainCounters counters, ConsumerMarker cm) { q.drainTo((s, b) -> { counters.drained++; return true; }, 1000); }
@Benchmark @Group("high_contention") @GroupThreads(8) public void high_contention_offer(OfferCounters counters) { if (q.offer(ONE, 1)) { counters.offersMade++; } else { counters.offersFailed++; } }
@Benchmark @Group("high_contention") @GroupThreads(1) public void high_contention_drain(DrainCounters counters, ConsumerMarker cm) { q.drainTo((s, b) -> { counters.drained++; return true; }, 1000); }
@Benchmark @Group("run_together") public boolean contains1() { int needle = 1; byte[] haystack = soggyBottoms; return containsNeedle1(needle, haystack); }
@Benchmark @Group("run_together") public boolean contains1ToK() { byte[] haystack = soggyBottoms; for (int needle = 1; needle <= k; needle++) { if (containsNeedle2(needle, haystack)) { return true; } } return false; }
@Benchmark @Group("run_together") public Object safepoint() { if (intervalMs == 0) return null; LockSupport.parkNanos(intervalMs * 1000000); return safepointMethod(); }
@Benchmark @Group("run_together") public void park() { if (intervalMs == 0) return; LockSupport.parkNanos(intervalMs * 1000000); }
@GenerateMicroBenchmark @Group("tpt") public void offer(OpCounters counters) { if (!q.offer(ONE)) { counters.offerFail++; } if (DELAY_PRODUCER != 0) { BlackHole.consumeCPU(DELAY_PRODUCER); } }
@GenerateMicroBenchmark @Group("tpt") public void poll(OpCounters counters, ConsumerMarker cm) { if (q.poll() == null) { counters.pollFail++; } if (DELAY_CONSUMER != 0) { BlackHole.consumeCPU(DELAY_CONSUMER); } }
@GenerateMicroBenchmark @Group("tpt") public void offer(OpCounters counters) { if (!q.offer(ONE)) { counters.offerFail++; Thread.yield(); } if (DELAY_PRODUCER != 0) { BlackHole.consumeCPU(DELAY_PRODUCER); } }
@GenerateMicroBenchmark @Group("tpt") public void poll(OpCounters counters, ConsumerMarker cm) { if (q.poll() == null) { counters.pollFail++; Thread.yield(); } if (DELAY_CONSUMER != 0) { BlackHole.consumeCPU(DELAY_CONSUMER); } }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("circularBuffer") @GroupThreads(1) public void circularBufferAddEvent() { circularFifoBuffer.add(event); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("circularBuffer") @GroupThreads(1) public void circularBufferToList(Blackhole bh) { List<Object> events = circularFifoBuffer.toList(); bh.consume(events); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("circularBuffer") @GroupThreads(1) public void circularBufferSize(Blackhole bh) { int size = circularFifoBuffer.size(); bh.consume(size); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("circularBuffer") @GroupThreads(1) public void circularBufferTakeEvent(Blackhole bh) { Option<Object> event = circularFifoBuffer.take(); bh.consume(event); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("concurrentEvictingQueue") @GroupThreads(2) public void concurrentEvictingQueueAdd() { queue.add(event); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("concurrentEvictingQueue") @GroupThreads(1) public void concurrentEvictingQueueSize(Blackhole bh) { int size = queue.size(); bh.consume(size); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("concurrentEvictingQueue") @GroupThreads(1) public void concurrentEvictingQueuePoll(Blackhole bh) { Object event = queue.poll(); bh.consume(event); }
@Benchmark @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) @Group("concurrentEvictingQueue") @GroupThreads(1) public void concurrentEvictingQueuePeek(Blackhole bh) { Object event = queue.peek(); bh.consume(event); }
/** * */ @Benchmark @Group("park") public void park() { if (thread == null) thread = Thread.currentThread(); LockSupport.park(thread); }
/** * */ @Benchmark @GroupThreads(THREAD_COUNT) @Group("park") public void unpark() { LockSupport.unpark(thread); }
/** * */ @Benchmark @Group("condition") @GroupThreads(THREAD_COUNT) public void notifyAll0() { synchronized (mux) { mux.notify(); } }
/** * */ @Benchmark @Group("condition") public void wait0() throws InterruptedException { synchronized (mux) { mux.wait(); } }
@Benchmark @Group("trackImmediate") public void trackImmediateAcks(Control control, TrackerState trackerState) throws Exception { if (!control.stopMeasurement) { AcknowledgableWatermark wmark = new AcknowledgableWatermark(new DefaultCheckpointableWatermark( "0", new LongWatermark(trackerState._index))); trackerState._watermarkTracker.track(wmark); trackerState._index++; wmark.ack(); } }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") public void test(MyState state) { state.tickRun = TICKER.incrementAndGet(); Fixtures.work(); }