Skip to content

Commit

Permalink
Fix TPS calculations
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 8f1dfa5 commit 7f690cf
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Benchmarking {
static final int LATENCY_MIN = 100000;
static final int LATENCY_MAX = 10000000;
static final int LATENCY_MULTIPLIER = 10000;
static final double TPS_NORMALIZATION = 1000000000.0; // nano to seconds

private static ChosenAction randomAction() {
if (Math.random() > PROB_GET) {
Expand Down Expand Up @@ -130,15 +131,15 @@ public static void printResults(
LatencyResults results = entry.getValue();

try {
resultsFile.write(
resultsFile.append(
"Avg. time in ms per " + action + ": " + results.avgLatency / LATENCY_NORMALIZATION);
resultsFile.write(
resultsFile.append(
action + " p50 latency in ms: " + results.p50Latency / LATENCY_NORMALIZATION);
resultsFile.write(
resultsFile.append(
action + " p90 latency in ms: " + results.p90Latency / LATENCY_NORMALIZATION);
resultsFile.write(
resultsFile.append(
action + " p99 latency in ms: " + results.p99Latency / LATENCY_NORMALIZATION);
resultsFile.write(
resultsFile.append(
action + " std dev in ms: " + results.stdDeviation / LATENCY_NORMALIZATION);
} catch (Exception ignored) {
}
Expand Down Expand Up @@ -244,13 +245,13 @@ public static void testClientSetGet(
config
.resultsFile
.get()
.append(
"Avg. time in ms: " + (after - before) / iterations / LATENCY_NORMALIZATION);
.append("TPS: %s%n" + (iterations / ((after - before) / TPS_NORMALIZATION)));
} catch (IOException ignored) {
}
} else {
System.out.println(
"Avg. time in ms: " + (after - before) / iterations / LATENCY_NORMALIZATION);
System.out.println("Runtime: " + ((after - before) / TPS_NORMALIZATION));
System.out.println("Iterations: " + iterations);
System.out.printf("TPS: %s%n", (iterations / ((after - before) / TPS_NORMALIZATION)));
}
}
}
Expand Down

0 comments on commit 7f690cf

Please sign in to comment.