@@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
3232
3333 CoverageSummary coverage = loadCoverage (arguments .coverageSummary , arguments .coverageHtmlUrl );
3434
35- SummaryAndComment output = buildSummaryAndComment (data , title , marker , successMessage , coverage );
35+ SummaryAndComment output = buildSummaryAndComment (data , title , marker , successMessage , coverage , arguments . vmTime , arguments . compilationTime );
3636 writeLines (arguments .summaryOut , output .summaryLines );
3737 writeLines (arguments .commentOut , output .commentLines );
3838 }
@@ -51,7 +51,7 @@ private static void writeLines(Path path, List<String> lines) throws IOException
5151 Files .writeString (path , sb .toString (), StandardCharsets .UTF_8 );
5252 }
5353
54- private static SummaryAndComment buildSummaryAndComment (Map <String , Object > data , String title , String marker , String successMessage , CoverageSummary coverage ) {
54+ private static SummaryAndComment buildSummaryAndComment (Map <String , Object > data , String title , String marker , String successMessage , CoverageSummary coverage , Long vmTime , Long compilationTime ) {
5555 List <String > summaryLines = new ArrayList <>();
5656 List <String > commentLines = new ArrayList <>();
5757 Object resultsObj = data .get ("results" );
@@ -148,22 +148,34 @@ private static SummaryAndComment buildSummaryAndComment(Map<String, Object> data
148148
149149 appendCoverageComment (commentLines , coverage );
150150
151- if (commentLines .isEmpty ()) {
151+ // If no visual regressions or errors were found (commentEntries is empty),
152+ // we should display the success message.
153+ // However, we also need to include benchmark results.
154+ if (commentEntries .isEmpty ()) {
152155 commentLines .add (successMessage != null ? successMessage : DEFAULT_SUCCESS_MESSAGE );
153156 commentLines .add ("" );
154- comparisonOverviewAdded = appendComparisonOverview (commentLines , comparisonSummary );
155- appendCoverageComment (commentLines , coverage );
156- } else if (commentLines .size () == 1 && commentLines .get (0 ).isEmpty ()) {
157- commentLines .add (successMessage != null ? successMessage : DEFAULT_SUCCESS_MESSAGE );
158- commentLines .add ("" );
159- comparisonOverviewAdded = appendComparisonOverview (commentLines , comparisonSummary );
157+ if (!comparisonOverviewAdded ) {
158+ comparisonOverviewAdded = appendComparisonOverview (commentLines , comparisonSummary );
159+ }
160160 appendCoverageComment (commentLines , coverage );
161161 }
162162
163- if (commentLines .isEmpty ()) {
164- commentLines .add (successMessage != null ? successMessage : DEFAULT_SUCCESS_MESSAGE );
165- commentLines .add ("" );
166- appendComparisonOverview (commentLines , comparisonSummary );
163+ // Add benchmark results at the end
164+ appendBenchmarkResults (commentLines , vmTime , compilationTime );
165+
166+ if (commentLines .isEmpty () || (commentLines .size () == 1 && commentLines .get (0 ).isEmpty ())) {
167+ // This fallback block might be redundant now, but kept for safety.
168+ // If for some reason we still have empty lines (e.g. no benchmarks and no visual changes and logic skipped above),
169+ // ensure we output something.
170+ if (commentEntries .isEmpty ()) {
171+ if (commentLines .isEmpty () || !commentLines .contains (successMessage != null ? successMessage : DEFAULT_SUCCESS_MESSAGE )) {
172+ commentLines .add (0 , successMessage != null ? successMessage : DEFAULT_SUCCESS_MESSAGE );
173+ commentLines .add (1 , "" );
174+ }
175+ }
176+ if (!comparisonOverviewAdded ) {
177+ comparisonOverviewAdded = appendComparisonOverview (commentLines , comparisonSummary );
178+ }
167179 }
168180
169181 if (marker != null && !marker .isEmpty ()) {
@@ -219,6 +231,24 @@ private static void appendCoverageSummary(List<String> summaryLines, CoverageSum
219231 }
220232 }
221233
234+ private static void appendBenchmarkResults (List <String > commentLines , Long vmTime , Long compilationTime ) {
235+ if (vmTime == null && compilationTime == null ) {
236+ return ;
237+ }
238+ if (!commentLines .isEmpty () && !commentLines .get (commentLines .size () - 1 ).isEmpty ()) {
239+ commentLines .add ("" );
240+ }
241+ commentLines .add ("### Benchmark Results" );
242+ commentLines .add ("" );
243+ if (vmTime != null ) {
244+ commentLines .add (String .format ("- **VM Translation Time:** %d seconds" , vmTime ));
245+ }
246+ if (compilationTime != null ) {
247+ commentLines .add (String .format ("- **Compilation Time:** %d seconds" , compilationTime ));
248+ }
249+ commentLines .add ("" );
250+ }
251+
222252 private static void appendCoverageComment (List <String > commentLines , CoverageSummary coverage ) {
223253 if (coverage == null ) {
224254 return ;
@@ -418,8 +448,10 @@ private static class Arguments {
418448 final String successMessage ;
419449 final Path coverageSummary ;
420450 final String coverageHtmlUrl ;
451+ final Long vmTime ;
452+ final Long compilationTime ;
421453
422- private Arguments (Path compareJson , Path commentOut , Path summaryOut , String marker , String title , String successMessage , Path coverageSummary , String coverageHtmlUrl ) {
454+ private Arguments (Path compareJson , Path commentOut , Path summaryOut , String marker , String title , String successMessage , Path coverageSummary , String coverageHtmlUrl , Long vmTime , Long compilationTime ) {
423455 this .compareJson = compareJson ;
424456 this .commentOut = commentOut ;
425457 this .summaryOut = summaryOut ;
@@ -428,6 +460,8 @@ private Arguments(Path compareJson, Path commentOut, Path summaryOut, String mar
428460 this .successMessage = successMessage ;
429461 this .coverageSummary = coverageSummary ;
430462 this .coverageHtmlUrl = coverageHtmlUrl ;
463+ this .vmTime = vmTime ;
464+ this .compilationTime = compilationTime ;
431465 }
432466
433467 static Arguments parse (String [] args ) {
@@ -439,6 +473,8 @@ static Arguments parse(String[] args) {
439473 String successMessage = null ;
440474 Path coverageSummary = null ;
441475 String coverageHtmlUrl = null ;
476+ Long vmTime = null ;
477+ Long compilationTime = null ;
442478 for (int i = 0 ; i < args .length ; i ++) {
443479 String arg = args [i ];
444480 switch (arg ) {
@@ -498,6 +534,30 @@ static Arguments parse(String[] args) {
498534 }
499535 coverageHtmlUrl = args [i ];
500536 }
537+ case "--vm-time" -> {
538+ if (++i >= args .length ) {
539+ System .err .println ("Missing value for --vm-time" );
540+ return null ;
541+ }
542+ try {
543+ vmTime = Long .parseLong (args [i ]);
544+ } catch (NumberFormatException e ) {
545+ System .err .println ("Invalid value for --vm-time: " + args [i ]);
546+ return null ;
547+ }
548+ }
549+ case "--compilation-time" -> {
550+ if (++i >= args .length ) {
551+ System .err .println ("Missing value for --compilation-time" );
552+ return null ;
553+ }
554+ try {
555+ compilationTime = Long .parseLong (args [i ]);
556+ } catch (NumberFormatException e ) {
557+ System .err .println ("Invalid value for --compilation-time: " + args [i ]);
558+ return null ;
559+ }
560+ }
501561 default -> {
502562 System .err .println ("Unknown argument: " + arg );
503563 return null ;
@@ -508,7 +568,7 @@ static Arguments parse(String[] args) {
508568 System .err .println ("--compare-json, --comment-out, and --summary-out are required" );
509569 return null ;
510570 }
511- return new Arguments (compare , comment , summary , marker , title , successMessage , coverageSummary , coverageHtmlUrl );
571+ return new Arguments (compare , comment , summary , marker , title , successMessage , coverageSummary , coverageHtmlUrl , vmTime , compilationTime );
512572 }
513573 }
514574
0 commit comments