16
16
from tqdm import tqdm
17
17
import argparse
18
18
19
+ from io import StringIO
20
+ import sys
21
+
19
22
from redis_benchmarks_specification .__common__ .github import (
20
23
update_comment_if_needed ,
21
24
create_new_pr_comment ,
@@ -583,7 +586,11 @@ def compute_regression_table(
583
586
)
584
587
(
585
588
detected_regressions ,
586
- table ,
589
+ table_full ,
590
+ table_stable ,
591
+ table_unstable ,
592
+ table_improvements ,
593
+ table_regressions ,
587
594
total_improvements ,
588
595
total_regressions ,
589
596
total_stable ,
@@ -619,35 +626,76 @@ def compute_regression_table(
619
626
baseline_str , comparison_str
620
627
)
621
628
)
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 = "" ,
629
683
headers = [
630
684
"Test Case" ,
631
685
"Baseline {} (median obs. +- std.dev)" .format (baseline_str ),
632
686
"Comparison {} (median obs. +- std.dev)" .format (comparison_str ),
633
687
"% change ({})" .format (metric_mode ),
634
688
"Note" ,
635
689
],
636
- value_matrix = table ,
690
+ value_matrix = table_full ,
637
691
)
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 "
645
693
646
- writer .dump (mystdout , False )
694
+ writer_full .dump (mystdout , False )
647
695
648
696
sys .stdout = old_stdout
649
-
650
- table_output = mystdout . getvalue ()
697
+ table_output += mystdout . getvalue ()
698
+ table_output += " \n </details> \n "
651
699
652
700
return (
653
701
detected_regressions ,
@@ -742,7 +790,11 @@ def from_rts_to_regression_table(
742
790
running_platform = None ,
743
791
):
744
792
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 = []
746
798
detected_regressions = []
747
799
total_improvements = 0
748
800
total_stable = 0
@@ -940,6 +992,25 @@ def from_rts_to_regression_table(
940
992
total_unstable += 1
941
993
942
994
should_add_line = False
995
+ line = get_line (
996
+ baseline_v_str ,
997
+ comparison_v_str ,
998
+ note ,
999
+ percentage_change ,
1000
+ test_name ,
1001
+ )
1002
+ if detected_regression :
1003
+ table_regressions .append (line )
1004
+
1005
+ if detected_improvement :
1006
+ table_improvements .append (line )
1007
+
1008
+ if unstable :
1009
+ table_unstable .append (line )
1010
+ else :
1011
+ if not detected_regression and not detected_improvement :
1012
+ table_stable .append (line )
1013
+
943
1014
if print_regressions_only and detected_regression :
944
1015
should_add_line = True
945
1016
if print_improvements_only and detected_improvement :
@@ -951,17 +1022,14 @@ def from_rts_to_regression_table(
951
1022
952
1023
if should_add_line :
953
1024
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
- )
1025
+ table_full .append (line )
962
1026
return (
963
1027
detected_regressions ,
964
- table ,
1028
+ table_full ,
1029
+ table_stable ,
1030
+ table_unstable ,
1031
+ table_improvements ,
1032
+ table_regressions ,
965
1033
total_improvements ,
966
1034
total_regressions ,
967
1035
total_stable ,
@@ -1037,6 +1105,23 @@ def get_test_names_from_db(rts, tags_regex_string, test_names, used_key):
1037
1105
return test_names
1038
1106
1039
1107
1108
+ def get_line (
1109
+ baseline_v_str ,
1110
+ comparison_v_str ,
1111
+ note ,
1112
+ percentage_change ,
1113
+ test_name ,
1114
+ ):
1115
+ percentage_change_str = "{:.1f}% " .format (percentage_change )
1116
+ return [
1117
+ test_name ,
1118
+ baseline_v_str ,
1119
+ comparison_v_str ,
1120
+ percentage_change_str ,
1121
+ note .strip (),
1122
+ ]
1123
+
1124
+
1040
1125
def add_line (
1041
1126
baseline_v_str ,
1042
1127
comparison_v_str ,
@@ -1045,15 +1130,14 @@ def add_line(
1045
1130
table ,
1046
1131
test_name ,
1047
1132
):
1048
- percentage_change_str = "{:.1f}% " .format (percentage_change )
1049
1133
table .append (
1050
- [
1051
- test_name ,
1134
+ get_line (
1052
1135
baseline_v_str ,
1053
1136
comparison_v_str ,
1054
- percentage_change_str ,
1055
- note .strip (),
1056
- ]
1137
+ note ,
1138
+ percentage_change ,
1139
+ test_name ,
1140
+ )
1057
1141
)
1058
1142
1059
1143
0 commit comments