From c22e5b16c4f2c599df63ce42fea67a145f702f76 Mon Sep 17 00:00:00 2001 From: Pascal Lais Date: Wed, 8 Dec 2021 09:31:37 +0100 Subject: [PATCH] Show execution time --- run_all.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run_all.py b/run_all.py index 97fb085..b5c7324 100644 --- a/run_all.py +++ b/run_all.py @@ -3,6 +3,7 @@ from os import listdir from os.path import isdir, isfile from subprocess import Popen, PIPE, CalledProcessError +from time import time for dir in [x for x in sorted(listdir('.')) if isdir(x)]: @@ -10,10 +11,11 @@ for dir in [x for x in sorted(listdir('.')) if isdir(x)]: input = dir + '/input.txt' if isfile(file) and isfile(input): 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) - - + print(f'Runtime: {end_time-start_time:.2f} s')