@@ -52,34 +52,46 @@ def main(directory, additional_env_vars, save_name, compare_names, filter):
52
52
benchmarks = [benchmark for benchmark in benchmarks if filter .search (benchmark .name ())]
53
53
54
54
for benchmark in benchmarks :
55
- print (f"setting up { benchmark .name ()} ... " , end = '' , flush = True )
56
- benchmark .setup ()
57
- print ("complete." )
55
+ try :
56
+ print (f"setting up { benchmark .name ()} ... " , end = '' , flush = True )
57
+ benchmark .setup ()
58
+ print ("complete." )
59
+ except Exception as e :
60
+ if options .exit_on_failure :
61
+ raise e
62
+ else :
63
+ print (f"failed: { e } " )
58
64
59
65
results = []
60
66
for benchmark in benchmarks :
61
- merged_env_vars = {** additional_env_vars }
62
- iteration_results = []
63
- for iter in range (options .iterations ):
64
- print (f"running { benchmark .name ()} , iteration { iter } ... " , end = '' , flush = True )
65
- bench_results = benchmark .run (merged_env_vars )
66
- if bench_results is not None :
67
- print (f"complete ({ bench_results .value } { benchmark .unit ()} )." )
68
- iteration_results .append (bench_results )
67
+ try :
68
+ merged_env_vars = {** additional_env_vars }
69
+ iteration_results = []
70
+ for iter in range (options .iterations ):
71
+ print (f"running { benchmark .name ()} , iteration { iter } ... " , end = '' , flush = True )
72
+ bench_results = benchmark .run (merged_env_vars )
73
+ if bench_results is not None :
74
+ print (f"complete ({ bench_results .value } { benchmark .unit ()} )." )
75
+ iteration_results .append (bench_results )
76
+ else :
77
+ print (f"did not finish." )
78
+
79
+ if len (iteration_results ) == 0 :
80
+ continue
81
+
82
+ iteration_results .sort (key = lambda res : res .value )
83
+ median_index = len (iteration_results ) // 2
84
+ median_result = iteration_results [median_index ]
85
+
86
+ median_result .unit = benchmark .unit ()
87
+ median_result .name = benchmark .name ()
88
+
89
+ results .append (median_result )
90
+ except Exception as e :
91
+ if options .exit_on_failure :
92
+ raise e
69
93
else :
70
- print (f"did not finish." )
71
-
72
- if len (iteration_results ) == 0 :
73
- continue
74
-
75
- iteration_results .sort (key = lambda res : res .value )
76
- median_index = len (iteration_results ) // 2
77
- median_result = iteration_results [median_index ]
78
-
79
- median_result .unit = benchmark .unit ()
80
- median_result .name = benchmark .name ()
81
-
82
- results .append (median_result )
94
+ print (f"failed: { e } " )
83
95
84
96
for benchmark in benchmarks :
85
97
print (f"tearing down { benchmark .name ()} ... " , end = '' , flush = True )
@@ -126,6 +138,7 @@ def validate_and_parse_env_args(env_args):
126
138
parser .add_argument ("--timeout" , type = int , help = 'Timeout for individual benchmarks in seconds.' , default = 600 )
127
139
parser .add_argument ("--filter" , type = str , help = 'Regex pattern to filter benchmarks by name.' , default = None )
128
140
parser .add_argument ("--verbose" , help = 'Print output of all the commands.' , action = "store_true" )
141
+ parser .add_argument ("--exit_on_failure" , help = 'Exit on first failure.' , action = "store_true" )
129
142
130
143
args = parser .parse_args ()
131
144
additional_env_vars = validate_and_parse_env_args (args .env )
@@ -137,6 +150,7 @@ def validate_and_parse_env_args(env_args):
137
150
options .timeout = args .timeout
138
151
options .ur_dir = args .ur_dir
139
152
options .ur_adapter_name = args .ur_adapter_name
153
+ options .exit_on_failure = args .exit_on_failure
140
154
141
155
benchmark_filter = re .compile (args .filter ) if args .filter else None
142
156
0 commit comments