1616from tqdm import tqdm
1717import argparse
1818
19+ from io import StringIO
20+ import sys
21+
1922from redis_benchmarks_specification .__common__ .github import (
2023 update_comment_if_needed ,
2124 create_new_pr_comment ,
@@ -583,7 +586,11 @@ def compute_regression_table(
583586 )
584587 (
585588 detected_regressions ,
586- table ,
589+ table_full ,
590+ table_stable ,
591+ table_unstable ,
592+ table_improvements ,
593+ table_regressions ,
587594 total_improvements ,
588595 total_regressions ,
589596 total_stable ,
@@ -619,35 +626,76 @@ def compute_regression_table(
619626 baseline_str , comparison_str
620627 )
621628 )
622- writer = MarkdownTableWriter (
623- table_name = "Comparison between {} and {}.\n \n Time Period from {}. (environment used: {})\n " .format (
624- baseline_str ,
625- comparison_str ,
626- from_human_str ,
627- baseline_deployment_name ,
628- ),
629+
630+ table_output = "# Comparison between {} and {}.\n \n Time Period from {}. (environment used: {})\n \n " .format (
631+ baseline_str ,
632+ comparison_str ,
633+ from_human_str ,
634+ baseline_deployment_name ,
635+ )
636+
637+ if total_regressions > 0 :
638+ old_stdout = sys .stdout
639+ sys .stdout = mystdout = StringIO ()
640+ table_output += "#### Regressions Table\n \n "
641+ writer_regressions = MarkdownTableWriter (
642+ table_name = "" ,
643+ headers = [
644+ "Test Case" ,
645+ "Baseline {} (median obs. +- std.dev)" .format (baseline_str ),
646+ "Comparison {} (median obs. +- std.dev)" .format (comparison_str ),
647+ "% change ({})" .format (metric_mode ),
648+ "Note" ,
649+ ],
650+ value_matrix = table_regressions ,
651+ )
652+ writer_regressions .dump (mystdout , False )
653+ table_output += mystdout .getvalue ()
654+ table_output += "\n \n "
655+ mystdout .close ()
656+ sys .stdout = old_stdout
657+
658+ if total_improvements > 0 :
659+ old_stdout = sys .stdout
660+ sys .stdout = mystdout = StringIO ()
661+ table_output += "#### Improvements Table\n \n "
662+ writer_regressions = MarkdownTableWriter (
663+ table_name = "" ,
664+ headers = [
665+ "Test Case" ,
666+ "Baseline {} (median obs. +- std.dev)" .format (baseline_str ),
667+ "Comparison {} (median obs. +- std.dev)" .format (comparison_str ),
668+ "% change ({})" .format (metric_mode ),
669+ "Note" ,
670+ ],
671+ value_matrix = table_improvements ,
672+ )
673+ writer_regressions .dump (mystdout , False )
674+ table_output += mystdout .getvalue ()
675+ table_output += "\n \n "
676+ mystdout .close ()
677+ sys .stdout = old_stdout
678+
679+ old_stdout = sys .stdout
680+ sys .stdout = mystdout = StringIO ()
681+ writer_full = MarkdownTableWriter (
682+ table_name = "" ,
629683 headers = [
630684 "Test Case" ,
631685 "Baseline {} (median obs. +- std.dev)" .format (baseline_str ),
632686 "Comparison {} (median obs. +- std.dev)" .format (comparison_str ),
633687 "% change ({})" .format (metric_mode ),
634688 "Note" ,
635689 ],
636- value_matrix = table ,
690+ value_matrix = table_full ,
637691 )
638- table_output = ""
639-
640- from io import StringIO
641- import sys
642-
643- old_stdout = sys .stdout
644- sys .stdout = mystdout = StringIO ()
692+ table_output += "<details>\n <summary>Full Results table:</summary>\n \n "
645693
646- writer .dump (mystdout , False )
694+ writer_full .dump (mystdout , False )
647695
648696 sys .stdout = old_stdout
649-
650- table_output = mystdout . getvalue ()
697+ table_output += mystdout . getvalue ()
698+ table_output += " \n </details> \n "
651699
652700 return (
653701 detected_regressions ,
@@ -742,7 +790,11 @@ def from_rts_to_regression_table(
742790 running_platform = None ,
743791):
744792 print_all = print_regressions_only is False and print_improvements_only is False
745- table = []
793+ table_full = []
794+ table_unstable = []
795+ table_stable = []
796+ table_regressions = []
797+ table_improvements = []
746798 detected_regressions = []
747799 total_improvements = 0
748800 total_stable = 0
@@ -752,6 +804,10 @@ def from_rts_to_regression_table(
752804 noise_waterline = 3
753805 progress = tqdm (unit = "benchmark time-series" , total = len (test_names ))
754806 for test_name in test_names :
807+ compare_version = "v0.1.208"
808+ github_link = "https://github.com/redis/redis-benchmarks-specification/blob"
809+ test_path = f"redis_benchmarks_specification/test-suites/{ test_name } .yml"
810+ test_link = f"[{ test_name } ]({ github_link } /{ compare_version } /{ test_path } )"
755811 multi_value_baseline = check_multi_value_filter (baseline_str )
756812 multi_value_comparison = check_multi_value_filter (comparison_str )
757813
@@ -940,6 +996,25 @@ def from_rts_to_regression_table(
940996 total_unstable += 1
941997
942998 should_add_line = False
999+ line = get_line (
1000+ baseline_v_str ,
1001+ comparison_v_str ,
1002+ note ,
1003+ percentage_change ,
1004+ test_link ,
1005+ )
1006+ if detected_regression :
1007+ table_regressions .append (line )
1008+
1009+ if detected_improvement :
1010+ table_improvements .append (line )
1011+
1012+ if unstable :
1013+ table_unstable .append (line )
1014+ else :
1015+ if not detected_regression and not detected_improvement :
1016+ table_stable .append (line )
1017+
9431018 if print_regressions_only and detected_regression :
9441019 should_add_line = True
9451020 if print_improvements_only and detected_improvement :
@@ -951,17 +1026,14 @@ def from_rts_to_regression_table(
9511026
9521027 if should_add_line :
9531028 total_comparison_points = total_comparison_points + 1
954- add_line (
955- baseline_v_str ,
956- comparison_v_str ,
957- note ,
958- percentage_change ,
959- table ,
960- test_name ,
961- )
1029+ table_full .append (line )
9621030 return (
9631031 detected_regressions ,
964- table ,
1032+ table_full ,
1033+ table_stable ,
1034+ table_unstable ,
1035+ table_improvements ,
1036+ table_regressions ,
9651037 total_improvements ,
9661038 total_regressions ,
9671039 total_stable ,
@@ -1037,6 +1109,23 @@ def get_test_names_from_db(rts, tags_regex_string, test_names, used_key):
10371109 return test_names
10381110
10391111
1112+ def get_line (
1113+ baseline_v_str ,
1114+ comparison_v_str ,
1115+ note ,
1116+ percentage_change ,
1117+ test_name ,
1118+ ):
1119+ percentage_change_str = "{:.1f}% " .format (percentage_change )
1120+ return [
1121+ test_name ,
1122+ baseline_v_str ,
1123+ comparison_v_str ,
1124+ percentage_change_str ,
1125+ note .strip (),
1126+ ]
1127+
1128+
10401129def add_line (
10411130 baseline_v_str ,
10421131 comparison_v_str ,
@@ -1045,15 +1134,14 @@ def add_line(
10451134 table ,
10461135 test_name ,
10471136):
1048- percentage_change_str = "{:.1f}% " .format (percentage_change )
10491137 table .append (
1050- [
1051- test_name ,
1138+ get_line (
10521139 baseline_v_str ,
10531140 comparison_v_str ,
1054- percentage_change_str ,
1055- note .strip (),
1056- ]
1141+ note ,
1142+ percentage_change ,
1143+ test_name ,
1144+ )
10571145 )
10581146
10591147
0 commit comments