From 8f070531f588af10c76bc3c8693364c710e4f67e Mon Sep 17 00:00:00 2001 From: Martin Blazik Date: Wed, 4 Nov 2020 13:37:36 +0100 Subject: [PATCH] tss script can measure aech command duration --- bin/tss | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/tss b/bin/tss index 346f1ad..f682fdf 100755 --- a/bin/tss +++ b/bin/tss @@ -1,9 +1,17 @@ #!/usr/bin/env python3 -from sys import stdin, stdout +from sys import stdin, stdout, argv from time import time +detailed = '-d' in argv start = time() +last = start for line in stdin: - stamp = time() - start - stdout.write(f"{stamp:0.6f} {line}") + now = time() + duration = now - start + diff = now - last + last = now + if detailed: + stdout.write(f"{duration:0.6f} [{diff:0.6f}] {line}") + else: + stdout.write(f"{duration:0.6f} {line}")