diff --git a/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java b/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java index fcfc92fcc0..50172402d5 100644 --- a/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java +++ b/java/jabushka/benchmarks/src/main/java/javabushka/client/BenchmarkingApp.java @@ -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 { diff --git a/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java b/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java index a4deb902f1..22569fceab 100644 --- a/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java +++ b/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Benchmarking.java @@ -1,6 +1,5 @@ package javabushka.client.utils; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -8,6 +7,7 @@ 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; @@ -112,19 +112,23 @@ public static Map calculateResults( } public static void printResults( - Map calculatedResults, String resultsFile) { - if (resultsFile != null) { + Map 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 resultsMap) { + public static void printResults(Map resultsMap, String clientName) { + System.out.printf("%n =====> %s <===== %n%n", clientName); for (Map.Entry entry : resultsMap.entrySet()) { ChosenAction action = entry.getKey(); LatencyResults results = entry.getValue(); @@ -135,6 +139,7 @@ public static void printResults(Map 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 measurePerformance( diff --git a/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Reporting.java b/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Reporting.java index 463e348fa8..ce5845a3bd 100644 --- a/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Reporting.java +++ b/java/jabushka/benchmarks/src/main/java/javabushka/client/utils/Reporting.java @@ -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 calculatedResults, String resultsFile) throws IOException { + Map calculatedResults, + RunConfiguration runConfiguration, + String clientName) + throws IOException { Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create(); Collection recordings = new ArrayList<>(); - Path path = Path.of(resultsFile); + Path path = Path.of(runConfiguration.resultsFile); if (Files.exists(path)) { TypeToken> 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; diff --git a/java/jabushka/benchmarks/src/test/java/javabushka/client/jedis/JedisClientIT.java b/java/jabushka/benchmarks/src/test/java/javabushka/client/jedis/JedisClientIT.java index 09a0e7ef35..e63aa20347 100644 --- a/java/jabushka/benchmarks/src/test/java/javabushka/client/jedis/JedisClientIT.java +++ b/java/jabushka/benchmarks/src/test/java/javabushka/client/jedis/JedisClientIT.java @@ -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"); } }