Skip to content

Commit

Permalink
Add TPS for all async items
Browse files Browse the repository at this point in the history
Signed-off-by: acarbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Oct 11, 2023
1 parent 49654c3 commit b3284c1
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package javababushka.benchmarks.utils;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -221,6 +222,7 @@ public static void testClientSetGet(
"===> concurrentNum = %d, clientNum = %d, tasks = %d%n",
concurrentNum, clientCount, tasks.size());
}
long before = System.nanoTime();
tasks.stream()
.map(CompletableFuture::runAsync)
.forEach(
Expand All @@ -231,8 +233,22 @@ public static void testClientSetGet(
e.printStackTrace();
}
});
long after = System.nanoTime();

// print results per action
printResults(calculateResults(actionResults), config.resultsFile);

// print TPS
if (config.resultsFile.isPresent()) {
try {
config.resultsFile.get().append(
"Avg. time in ms: " + (after - before) / iterations / LATENCY_NORMALIZATION);
} catch (IOException ignored) {
}
} else {
System.out.println(
"Avg. time in ms: " + (after - before) / iterations / LATENCY_NORMALIZATION);
}
}
}
}
Expand Down

0 comments on commit b3284c1

Please sign in to comment.