@@ -76,6 +76,9 @@ public static void main(String[] args) throws Exception {
76
76
}
77
77
logger .info ("\n Benchmark complete! CloudWatch metrics published with run ID: " + runId );
78
78
79
+ // Print benchmark results summary
80
+ printBenchmarkSummary (allResults );
81
+
79
82
} finally {
80
83
publisher .shutdown ();
81
84
}
@@ -107,28 +110,103 @@ private static BenchmarkResult convertToBenchmarkResult(String clientType,
107
110
RunResult runResult ) {
108
111
String fullBenchmarkName = runResult .getPrimaryResult ().getLabel ();
109
112
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 );
115
116
116
117
// 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 ));
118
119
119
120
double throughput = runResult .getPrimaryResult ().getScore ();
120
121
double avgLatency = 1000.0 / throughput ;
121
122
double p99Latency = avgLatency * 1.5 ;
122
123
123
124
int threadCount = benchmarkName .contains ("multiThreaded" ) ? 10 : 1 ;
124
125
126
+ // Include parameters in the benchmark name for uniqueness
127
+ String fullName = parameters .isEmpty () ? benchmarkName : benchmarkName + " " + parameters ;
128
+
125
129
return new BenchmarkResult (
126
130
clientType ,
127
- benchmarkName ,
131
+ fullName ,
128
132
throughput ,
129
133
avgLatency ,
130
134
p99Latency ,
131
135
threadCount
132
136
);
133
137
}
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
+ }
134
212
}
0 commit comments