Created
September 5, 2017 22:51
-
-
Save nascheme/0bff5c49bb6b518f5ce23a9aea27f14b to your computer and use it in GitHub Desktop.
Pretty printer for module import dtrace output
This file contains 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
!/usr/bin/env python3 | |
# | |
# Pretty print module import dtrace output. First column is elapsed time in ms. Second column is % of total time. | |
import sys | |
import fileinput | |
def main(): | |
first = None | |
lines = [] | |
for line in fileinput.input(): | |
if not line.strip(): | |
break | |
ts, _, rest = line.partition('\t') | |
ts = int(ts) | |
rest = rest.strip() | |
if first is None: | |
first = ts | |
ts = 0 | |
else: | |
ts -= first | |
lines.append((ts, rest)) | |
last = ts | |
for ts, line in lines: | |
print('%8.3f %6.1f %s' % (float(ts)/1e6, 100*float(ts)/last, line)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment