diff --git a/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java b/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java index 70dfe2d940..bae34c9373 100644 --- a/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java +++ b/java/benchmarks/src/main/java/javababushka/benchmarks/utils/Benchmarking.java @@ -176,11 +176,8 @@ public static void testClientSetGet( "%n concurrent = %d/%d, client# = %d/%d%n", finalI, concurrentNum, finalJ + 1, clientNum); } - while (true) { - int iterationIncrement = iterationCounter.getAndIncrement(); - if (iterationIncrement >= iterations) { - break; - } + int iterationIncrement = iterationCounter.getAndIncrement(); + while (iterationIncrement < iterations) { if (config.debugLogging) { System.out.printf( "> iteration = %d/%d, client# = %d/%d%n", @@ -190,6 +187,8 @@ public static void testClientSetGet( Pair result = measurePerformance(client, config.dataSize, async); actionResults.get(result.getLeft()).add(result.getRight()); + + iterationIncrement = iterationCounter.getAndIncrement(); } }); } @@ -226,17 +225,26 @@ public static Pair measurePerformance( actions.put( ChosenAction.GET_EXISTING, async - ? () -> ((AsyncClient) client).asyncGet(generateKeySet()).get(ASYNC_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS) + ? () -> + ((AsyncClient) client) + .asyncGet(generateKeySet()) + .get(ASYNC_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS) : () -> ((SyncClient) client).get(generateKeySet())); actions.put( ChosenAction.GET_NON_EXISTING, async - ? () -> ((AsyncClient) client).asyncGet(generateKeyGet()).get(ASYNC_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS) + ? () -> + ((AsyncClient) client) + .asyncGet(generateKeyGet()) + .get(ASYNC_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS) : () -> ((SyncClient) client).get(generateKeyGet())); actions.put( ChosenAction.SET, async - ? () -> ((AsyncClient) client).asyncSet(generateKeySet(), value).get(ASYNC_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS) + ? () -> + ((AsyncClient) client) + .asyncSet(generateKeySet(), value) + .get(ASYNC_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS) : () -> ((SyncClient) client).set(generateKeySet(), value)); return getLatency(actions);