Files
advent-of-code-2021/run_all.py
Pascal Lais a5229f5209
All checks were successful
continuous-integration/drone/push Build is passing
Increase resolution for runtime
2021-12-11 14:53:09 +01:00

28 lines
928 B
Python
Executable File

#!/usr/bin/python3
from os import listdir
from os.path import isdir, isfile
from subprocess import Popen, PIPE, CalledProcessError
from time import time
total_run_time = 0
for dir in [x for x in sorted(listdir('.')) if isdir(x)]:
file = dir + '/' + dir + '.py'
input = dir + '/input.txt'
if isfile(file) and isfile(input):
print('--------------------------------')
print(dir, ':', sep='')
start_time = time()
with Popen(["python3", file], stdout=PIPE, bufsize=1, universal_newlines=True) as p:
for b in p.stdout:
print(b, end='')
end_time = time()
if p.returncode != 0:
raise CalledProcessError(p.returncode, p.args)
run_time = end_time-start_time
total_run_time += run_time
print(f'Runtime: {run_time:.3f} s')
print('--------------------------------')
print(f'Total runtime: {total_run_time:.3f} s')