-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze.py
39 lines (30 loc) · 985 Bytes
/
analyze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import re
import os
import glob
from pprint import pprint
import matplotlib
matplotlib.use('Agg')
analyze_pattern = re.compile('.*.analyze.log')
explain = re.compile('.*.explainonly.log')
def parse_analyze_log(logfile):
content = None
with open(logfile) as r:
content = r.read()
return {
'planningTime': re.findall('Planning Time: (\d+.\d+) ms', content),
'executionTime': re.findall('Execution Time: (\d+.\d+) ms', content)
}
def parse_all_analyze():
import matplotlib.pyplot as plt
res = {}
for logfile in glob.glob('logs/*.analyze.log'):
sqlname = re.findall('logs/(.*).analyze.log', logfile)[0]
res[sqlname] = parse_analyze_log(logfile)
# draw png
for sqlname in res:
data = res[sqlname]['executionTime']
plt.bar(range(len(data)), data)
pngname = 'png/%s.png' % sqlname
print('save executionTime for %s' % sqlname)
plt.savefig(pngname)
parse_all_analyze()