From f829e951a7988cfc228af56fbcf17057cb61c06c Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Fri, 16 Jun 2017 13:14:44 +0200 Subject: [PATCH] Added elapsed time in logging. --- cnn-svrt.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cnn-svrt.py b/cnn-svrt.py index 694f035..aa3690d 100755 --- a/cnn-svrt.py +++ b/cnn-svrt.py @@ -78,11 +78,20 @@ args = parser.parse_args() ###################################################################### log_file = open(args.log_file, 'w') +pred_log_t = None print(Fore.RED + 'Logging into ' + args.log_file + Style.RESET_ALL) def log_string(s): - s = Fore.GREEN + time.ctime() + Style.RESET_ALL + ' ' + s + global pred_log_t + t = time.time() + + if pred_log_t is None: + elapsed = 'start' + else: + elapsed = '+{:.02f}s'.format(t - pred_log_t) + pred_log_t = t + s = Fore.BLUE + time.ctime() + ' ' + Fore.GREEN + elapsed + Style.RESET_ALL + ' ' + s log_file.write(s + '\n') log_file.flush() print(s) -- 2.39.5