Skip to content

Instantly share code, notes, and snippets.



Last active Apr 7, 2019
What would you like to do?
Sum and sort 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"):
m = r.match(line)
assert m
time =
desc =
# strip tail of `codegen passes [incr module name]`
if desc.startswith("codegen passes"):
desc = "codegen passes"
if desc.startswith("llvm module passes"):
desc = "llvm module passes"
if desc.startswith("llvm function passes"):
desc = "llvm function passes"
if desc.startswith("encode_query_results"):
desc = "encode_query_results"
if desc.startswith("solve_nll_region_constraints"):
desc = "solve_nll_region_constraints"
if desc.startswith("ll link"):
desc = "ll link"
if desc.startswith("decode"):
desc = "decode"
if desc.startswith("altering"):
desc = "altering"
time = float(time)
if map.get(desc):
map[desc] = map[desc] + time
map[desc] = time
sorted = sorted(map.items(), key=operator.itemgetter(1))
for (time, pass_name) in sorted:
print("{} - {:.2f}".format(time, pass_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment