From b3f2909a29d991c1de8de60e4394f99ea052b1b1 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Sat, 15 Jun 2024 18:34:38 -0700 Subject: [PATCH] Print debug info with less overhead --- src/test/java/blackbox/slow/PoolIT.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/blackbox/slow/PoolIT.java b/src/test/java/blackbox/slow/PoolIT.java index c55ed610..1f45dcfd 100644 --- a/src/test/java/blackbox/slow/PoolIT.java +++ b/src/test/java/blackbox/slow/PoolIT.java @@ -290,6 +290,7 @@ void mustGraduallyReduceAggressivenessInRepairingFailingAllocator() throws Excep obj.expire(); obj.release(); assertThrows(PoolException.class, () -> pool.claim(longTimeout).release()); + StringBuilder sb = new StringBuilder(1024); long prev = 0, curr; for (int i = 0; i < 50; i++) { long start = System.nanoTime(); @@ -303,9 +304,12 @@ void mustGraduallyReduceAggressivenessInRepairingFailingAllocator() throws Excep } curr = counter.get(); long delta = curr - prev; - System.out.printf("i = %s, delta = %s%n", i, delta); + sb.append("i = ").append(i).append(", delta = ").append(delta).append('\n'); prev = curr; if (i > 40) { + if (delta > 5) { + System.out.print(sb); + } assertThat(delta).isLessThanOrEqualTo(5); } }