Created
November 6, 2021 14:11
-
-
Save DimanNe/0e8683caf75340e13c733f08563388ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
from datetime import datetime | |
import itertools as itl | |
def nwise(iterable, n=2): | |
iters = itl.tee(iterable, n) | |
for i, it in enumerate(iters): | |
next(itl.islice(it, i, i), None) | |
return zip(*iters) | |
first_time = None | |
fmt = '%H:%M:%S.%f' | |
for curr, nxt in nwise(fileinput.input(), 2): | |
# print(f'curr: {curr}') | |
# print(f'next: {nxt}') | |
try: | |
curr_time = datetime.strptime(curr.split()[0], fmt) | |
next_time = datetime.strptime(nxt.split()[0], fmt) | |
if not first_time: | |
first_time = curr_time | |
prev_str_time = first_time | |
diff_since_start = curr_time - first_time | |
this_cmd_duration = next_time - curr_time | |
print(f'{round(diff_since_start.total_seconds() * 1000, 3):.3f} / {round(this_cmd_duration.total_seconds() * 1000, 3):.3f} ms: {curr}', end='') | |
except: | |
print(f'{curr}', end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment