void () { int N = 1_000_000; AtomicInteger counter = new AtomicInteger(); Runnable r = () -> counter.incrementAndGet(); PlatformTestUtil.startPerformanceTest(getTestName(false), 20_000, () -> { for (int i = 0; i < N; i++) { if (i % 8192 == 0) { // decrease GC pressure, we're not measuring that SwingUtilities.invokeAndWait(EmptyRunnable.getInstance()); } SwingUtilities.invokeLater(r); } SwingUtilities.invokeAndWait(EmptyRunnable.getInstance()); assertEquals(N, counter.getAndSet(0)); }).assertTiming(); }