Skip to content

Commit e676762

Browse files
continue bloat-test.py after compilation error
If the compilation fails, the failed test is excluded and bloat-test.py will continue.
1 parent 6e6572a commit e676762

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

bloat-test.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os, re, sys
99
from contextlib import nested
1010
from glob import glob
11-
from subprocess import check_call, Popen, PIPE
11+
from subprocess import check_call, Popen, PIPE, CalledProcessError
1212
from timeit import timeit
1313

1414
template = r'''
@@ -175,8 +175,11 @@ def benchmark(flags):
175175
command = 'check_call({})'.format(
176176
[compiler_path, '-std=c++14', '-o', output_filename, include_dir] + sources + flags)
177177
result = Result()
178-
result.time = timeit(
179-
command, setup = 'from subprocess import check_call', number = 1)
178+
try:
179+
result.time = timeit(
180+
command, setup = 'from subprocess import check_call', number = 1)
181+
except CalledProcessError:
182+
return None
180183
print('Compile time: {:.2f}s'.format(result.time))
181184
result.size = os.stat(output_filename).st_size
182185
print('Size: {}'.format(result.size))
@@ -190,6 +193,7 @@ def benchmark(flags):
190193
if not expected_output:
191194
expected_output = output
192195
elif output != expected_output:
196+
print(output)
193197
raise Exception("output doesn't match")
194198
sys.stdout.flush()
195199
return result
@@ -244,14 +248,21 @@ def print_table(table, *formats):
244248
def to_kib(n):
245249
return int(round(n / 1024.0))
246250

251+
exclude_list = []
247252
NUM_RUNS = 3
248253
for config, flags in configs:
249254
results = {}
250255
for i in range(NUM_RUNS):
251256
for method, method_flags in methods:
257+
if method in exclude_list:
258+
continue
252259
print('Benchmarking', config, method)
253260
sys.stdout.flush()
254261
new_result = benchmark(flags + method_flags + sys.argv[1:])
262+
if not new_result:
263+
exclude_list.append(method)
264+
print(method + ' is not available')
265+
continue
255266
if method not in results:
256267
results[method] = new_result
257268
continue
@@ -265,6 +276,8 @@ def to_kib(n):
265276
('Method', 'Compile Time, s', 'Executable size, KiB', 'Stripped size, KiB')
266277
]
267278
for method, method_flags in methods:
279+
if method not in results:
280+
continue
268281
result = results[method]
269282
table.append(
270283
(method, result.time, to_kib(result.size), to_kib(result.stripped_size)))

0 commit comments

Comments
 (0)