Skip to content

Commit 59ac21f

Browse files
committed
updatded prints
1 parent 4833db9 commit 59ac21f

File tree

1 file changed

+85
-7
lines changed

1 file changed

+85
-7
lines changed

test/http-client-benchmarks/src/main/java/software/amazon/awssdk/benchmark/UnifiedBenchmarkRunner.java

Lines changed: 85 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public static void main(String[] args) throws Exception {
7676
}
7777
logger.info("\nBenchmark complete! CloudWatch metrics published with run ID: " + runId);
7878

79+
// Print benchmark results summary
80+
printBenchmarkSummary(allResults);
81+
7982
} finally {
8083
publisher.shutdown();
8184
}
@@ -107,28 +110,103 @@ private static BenchmarkResult convertToBenchmarkResult(String clientType,
107110
RunResult runResult) {
108111
String fullBenchmarkName = runResult.getPrimaryResult().getLabel();
109112

110-
// Extract just the method name (everything after the last dot)
111-
String benchmarkName = fullBenchmarkName;
112-
if (fullBenchmarkName.contains(".")) {
113-
benchmarkName = fullBenchmarkName.substring(fullBenchmarkName.lastIndexOf('.') + 1);
114-
}
113+
// Extract benchmark details including parameters
114+
String benchmarkName = extractBenchmarkName(fullBenchmarkName);
115+
String parameters = extractParameters(fullBenchmarkName);
115116

116117
// Log for debugging
117-
logger.info(String.format("Converting: %s -> %s", fullBenchmarkName, benchmarkName));
118+
logger.info(String.format("Converting: %s -> %s %s", fullBenchmarkName, benchmarkName, parameters));
118119

119120
double throughput = runResult.getPrimaryResult().getScore();
120121
double avgLatency = 1000.0 / throughput;
121122
double p99Latency = avgLatency * 1.5;
122123

123124
int threadCount = benchmarkName.contains("multiThreaded") ? 10 : 1;
124125

126+
// Include parameters in the benchmark name for uniqueness
127+
String fullName = parameters.isEmpty() ? benchmarkName : benchmarkName + " " + parameters;
128+
125129
return new BenchmarkResult(
126130
clientType,
127-
benchmarkName,
131+
fullName,
128132
throughput,
129133
avgLatency,
130134
p99Latency,
131135
threadCount
132136
);
133137
}
138+
139+
private static String extractBenchmarkName(String fullLabel) {
140+
if (fullLabel == null) return "unknown";
141+
142+
// JMH format: package.ClassName.methodName
143+
String methodPart = fullLabel;
144+
if (fullLabel.contains(".")) {
145+
methodPart = fullLabel.substring(fullLabel.lastIndexOf('.') + 1);
146+
}
147+
148+
// Remove parameter part if exists (after colon)
149+
if (methodPart.contains(":")) {
150+
methodPart = methodPart.substring(0, methodPart.indexOf(':'));
151+
}
152+
153+
return methodPart;
154+
}
155+
156+
private static String extractParameters(String fullLabel) {
157+
if (fullLabel == null || !fullLabel.contains(":")) {
158+
return "";
159+
}
160+
161+
// Extract everything after the colon (parameters)
162+
String params = fullLabel.substring(fullLabel.indexOf(':') + 1).trim();
163+
164+
// Format parameters nicely
165+
if (params.contains("(") && params.contains(")")) {
166+
params = params.substring(params.indexOf('(') + 1, params.lastIndexOf(')'));
167+
}
168+
169+
return "(" + params + ")";
170+
}
171+
172+
private static void printBenchmarkSummary(List<BenchmarkResult> results) {
173+
if (results == null || results.isEmpty()) {
174+
logger.warning("No benchmark results to display");
175+
return;
176+
}
177+
178+
System.out.println("\n" + "=".repeat(140));
179+
System.out.println("BENCHMARK RESULTS SUMMARY");
180+
System.out.println("=".repeat(140));
181+
182+
// Print header
183+
System.out.printf("%-20s | %-50s | %-15s | %-15s | %-15s | %-10s%n",
184+
"Client Type", "Benchmark", "Throughput", "Avg Latency", "P99 Latency", "Threads");
185+
System.out.println("-".repeat(140));
186+
187+
// Sort results for better readability
188+
List<BenchmarkResult> sortedResults = results.stream()
189+
.filter(r -> r != null && r.getClientType() != null && r.getBenchmarkName() != null)
190+
.sorted((a, b) -> {
191+
int clientCompare = a.getClientType().compareTo(b.getClientType());
192+
if (clientCompare != 0) return clientCompare;
193+
return a.getBenchmarkName().compareTo(b.getBenchmarkName());
194+
})
195+
.collect(Collectors.toList());
196+
197+
// Print all results (including parameter variations)
198+
for (BenchmarkResult result : sortedResults) {
199+
System.out.printf("%-20s | %-50s | %,13.2f/s | %13.2f ms | %13.2f ms | %10d%n",
200+
result.getClientType(),
201+
result.getBenchmarkName(),
202+
result.getThroughput(),
203+
result.getAvgLatency(),
204+
result.getP99Latency(),
205+
result.getThreadCount());
206+
}
207+
208+
System.out.println("=".repeat(140));
209+
System.out.printf("Total benchmark results: %d%n", sortedResults.size());
210+
System.out.println("=".repeat(140));
211+
}
134212
}

0 commit comments

Comments
 (0)