forked from reed-lau/cute-gemm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstat-csv.py
37 lines (27 loc) · 781 Bytes
/
stat-csv.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
from pprint import pprint
import numpy as np
def load_csv_and_stat(path):
with open(path, 'r') as fp:
lines = fp.readlines()
ret = {}
for line in lines:
if line.startswith('=='):
continue
fields = line.split(',\"')
kernel = fields[4].replace('"', '')
try:
usec = float(fields[-1].replace('"', '').replace(',', '.'))
except:
continue
if kernel not in ret:
ret[kernel] = [] # usec
ret[kernel].append(usec)
for k, s in ret.items():
s = np.array(s)
num = len(s)
mean = np.mean(s)
std = np.std(s)
med = np.median(s)
ret[k] = (mean, std, med, num)
pprint(ret)
load_csv_and_stat('a.csv')