Skip to content

Commit

Permalink
Add data size and client name to the report.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Sep 26, 2023
1 parent 9638f15 commit 93ffda5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,17 @@ private static RunConfiguration verifyOptions(CommandLine line) throws ParseExce
}

private static void testClientSetGet(Client client, RunConfiguration runConfiguration) {
System.out.printf("%n =====> %s <===== %n%n", client.getName());
Benchmarking.printResults(Benchmarking.measurePerformance(client, runConfiguration, false), runConfiguration.resultsFile);
System.out.println();
Benchmarking.printResults(
Benchmarking.measurePerformance(client, runConfiguration, false),
client.getName(),
runConfiguration);
}

private static void testAsyncClientSetGet(AsyncClient client, RunConfiguration runConfiguration) {
System.out.printf("%n =====> %s <===== %n%n", client.getName());
Benchmarking.printResults(Benchmarking.measurePerformance(client, runConfiguration, true), runConfiguration.resultsFile);
System.out.println();
Benchmarking.printResults(
Benchmarking.measurePerformance(client, runConfiguration, true),
client.getName(),
runConfiguration);
}

public enum ClientName {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package javabushka.client.utils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import javabushka.client.AsyncClient;
import javabushka.client.BenchmarkingApp;
import javabushka.client.BenchmarkingApp.RunConfiguration;
import javabushka.client.Client;
import javabushka.client.SyncClient;
import org.apache.commons.lang3.RandomStringUtils;
Expand Down Expand Up @@ -112,19 +112,23 @@ public static Map<ChosenAction, LatencyResults> calculateResults(
}

public static void printResults(
Map<ChosenAction, LatencyResults> calculatedResults, String resultsFile) {
if (resultsFile != null) {
Map<ChosenAction, LatencyResults> calculatedResults,
String clientName,
RunConfiguration runConfiguration) {
if (runConfiguration.resultsFile != null) {
try {
Reporting.WriteJson(calculatedResults, resultsFile);
Reporting.WriteJson(calculatedResults, runConfiguration, clientName);
} catch (Exception e) {
System.out.printf("Failed to write report file %s: %s%n", resultsFile, e.getMessage());
System.out.printf(
"Failed to write report file %s: %s%n", runConfiguration.resultsFile, e.getMessage());
e.printStackTrace(System.out);
}
}
printResults(calculatedResults);
printResults(calculatedResults, clientName);
}

public static void printResults(Map<ChosenAction, LatencyResults> resultsMap) {
public static void printResults(Map<ChosenAction, LatencyResults> resultsMap, String clientName) {
System.out.printf("%n =====> %s <===== %n%n", clientName);
for (Map.Entry<ChosenAction, LatencyResults> entry : resultsMap.entrySet()) {
ChosenAction action = entry.getKey();
LatencyResults results = entry.getValue();
Expand All @@ -135,6 +139,7 @@ public static void printResults(Map<ChosenAction, LatencyResults> resultsMap) {
System.out.println(action + " p99 latency in ms: " + results.p99Latency / 1000000.0);
System.out.println(action + " std dev in ms: " + results.stdDeviation / 1000000.0);
}
System.out.println();
}

public static Map<ChosenAction, LatencyResults> measurePerformance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,31 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import javabushka.client.BenchmarkingApp.RunConfiguration;
import lombok.Getter;

public class Reporting {

public static void WriteJson(
Map<ChosenAction, LatencyResults> calculatedResults, String resultsFile) throws IOException {
Map<ChosenAction, LatencyResults> calculatedResults,
RunConfiguration runConfiguration,
String clientName)
throws IOException {

Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create();
Collection<Measurements> recordings = new ArrayList<>();

Path path = Path.of(resultsFile);
Path path = Path.of(runConfiguration.resultsFile);
if (Files.exists(path)) {
TypeToken<Collection<Measurements>> collectionType = new TypeToken<>() {};
var json = new String(Files.readAllBytes(path));
recordings = gson.fromJson(json, collectionType);
}
var data = new Measurements();
// TODO: data_size, client, clientCount, num_of_tasks, is_cluster, tps
// TODO: clientCount, num_of_tasks, is_cluster, tps
data.data_size = runConfiguration.dataSize;
data.client = clientName;

data.get_existing_average_latency = calculatedResults.get(ChosenAction.GET_EXISTING).avgLatency;
data.get_existing_p50_latency = calculatedResults.get(ChosenAction.GET_EXISTING).p50Latency;
data.get_existing_p90_latency = calculatedResults.get(ChosenAction.GET_EXISTING).p90Latency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public void testResourceSetGet() {
actions.put(ChosenAction.SET, () -> jedisClient.set(Benchmarking.generateKeySet(), value));

Benchmarking.printResults(
Benchmarking.calculateResults(Benchmarking.getLatencies(iterations, actions)));
Benchmarking.calculateResults(Benchmarking.getLatencies(iterations, actions)), "jedis");
}
}

0 comments on commit 93ffda5

Please sign in to comment.