Skip to content

Instantly share code, notes, and snippets.

@brson
Last active April 7, 2019 03:05
Show Gist options
  • Save brson/bc52ab2bce7a600b32b4d25846a6c6c0 to your computer and use it in GitHub Desktop.
Save brson/bc52ab2bce7a600b32b4d25846a6c6c0 to your computer and use it in GitHub Desktop.
Script for accumulating and sorting output of rustc --Ztime-passes
import sys
import re
import operator
file = sys.argv[1]
r = re.compile("time: (\S.*); rss: (\S*)\s*(.*)")
map = { }
with open(file) as f:
for line in f:
line = line.strip()
if not line.startswith("time"):
pass
m = r.match(line)
assert m
time = m.group(1)
desc = m.group(3)
time = float(time)
if map.get(desc):
map[desc] = map[desc] + time
else:
map[desc] = time
sorted = sorted(map.items(), key=operator.itemgetter(1))
for (time, pass_name) in sorted:
print("{} - {}".format(time, pass_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment