github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/profiling/aggregate_timers.py (about) 1 #!/usr/bin/env python 2 3 # 4 # run on the outputted log of the tests with KEYBASE_TIMERS=a to figure 5 # out which are the slowest API calls. 6 # 7 import sys 8 import re 9 10 rxx = re.compile(r"timer: (.*?) \[(\d+) ms\]") 11 counts = {} 12 for line in sys.stdin: 13 m = rxx.search(line) 14 if m: 15 which = m.group(1) 16 time = int(m.group(2)) 17 if not counts.get(which): 18 counts[which] = 0 19 counts[which] += time 20 vec = counts.items() 21 vec.sort(key = lambda x: -x[1]) 22 for line in vec: 23 print line[1], "\t", line[0] 24