-
Notifications
You must be signed in to change notification settings - Fork 1
/
log2csv.py
executable file
·50 lines (46 loc) · 1.07 KB
/
log2csv.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
40
41
42
43
44
45
46
47
48
49
50
import sys
import re
# regex for the lines with relevant data
test_line = 'echo (.+) (.+) 1>&2 ; time -p.*touch .+\..*ran$'
gas_line = 'as used: +([0-9]+)'
secs_line = 'time: +([0-9.]+)'
# read in data
path = ''
client = ''
test = ''
clients = ['gas']
tests = []
data = {}
for line in sys.stdin:
match = re.search(test_line, line)
if match:
client = match.group(1)
test = match.group(2)
if client not in clients:
clients += [client]
if test not in tests:
tests += [test]
continue
match = re.search(gas_line, line)
if match:
if test not in data:
data[test] = {}
data[test]['gas'] = match.group(1)
continue
match = re.search(secs_line, line)
if match:
if test not in data:
data[test] = {}
data[test][client] = match.group(1)
continue
# print the header
sys.stdout.write("(sec/test)")
for client in clients:
sys.stdout.write(", %s" % client)
sys.stdout.write("\n")
# print the test, gas, secs, secs, ...
for test in tests:
sys.stdout.write("%s" % test)
for client in clients:
sys.stdout.write(", %s" % data[test].get(client,0))
sys.stdout.write("\n")