# HG changeset patch # User Nicolas Chauvat # Date 1231191025 -3600 # Node ID 1e12e8cd69013324931a73ceeaa840e41b1da25f # Parent 705866d6eee8e5d1b14dcbafaa08447719438470 exlog script to examine rql logs diff -r 705866d6eee8 -r 1e12e8cd6901 devtools/exlog.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/devtools/exlog.py Mon Jan 05 22:30:25 2009 +0100 @@ -0,0 +1,39 @@ +""" +usage: python exlog.py < rql.log + +will print out the following table + + total execution time || number of occurences || rql query + +sorted by descending total execution time + +chances are the lines at the top are the ones that will bring +the higher benefit after optimisation. Start there. +""" +import sys, re + +def run(): + requests = {} + for line in sys.stdin: + if not ' WHERE ' in line: + continue + #sys.stderr.write( line ) + rql, time = line.split('--') + rql = re.sub("(\'\w+': \d*)", '', rql) + req = requests.setdefault(rql, []) + time.strip() + chunks = time.split() + cputime = float(chunks[-3]) + req.append( cputime ) + + stat = [] + for rql, times in requests.items(): + stat.append( (sum(times), len(times), rql) ) + + stat.sort() + stat.reverse() + for time, occ, rql in stat: + print time, occ, rql + +if __name__ == '__main__': + run()