tss script can measure aech command duration

This commit is contained in:
Martin Blazik
2020-11-04 13:37:36 +01:00
parent c9e97b7d00
commit 8f070531f5

14
bin/tss
View File

@@ -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}")