-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess3.py
115 lines (99 loc) · 3.5 KB
/
process3.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python
import csv
import sys
import matplotlib.pyplot as plt
from textwrap import wrap
from sets import Set
from collections import defaultdict
file = sys.argv[1]
nclients=31
nthreads=4
## Expt,Key/Serv,#Serv,ValSize,Key/Read,WriteFrac,Zipf,Threads,Client,NumOps,NumKeys,NumColumns,NumBytes,NumReads,NumWrites,Duration,Throughput,Ravg,R50,R90,R99,Wavg,W50,W90,W99,#Tx2R,#K2R,#aggR,#aggW,Lsum,Lavg,P_R,AVG_RD,AVG_W,AVG_OP,Xput,Real Xput
def mean(x):
assert len(x)==nclients, ("Len = ",len(x))
return sum(x)/len(x)
def lsum(x):
assert len(x)==nclients, ("Len = ",len(x))
return sum(x)
def filterfn(x):
return x['Key/Read'] != '4' and x['WriteFrac'] == '0.05' and x['Zipf'] == '0.99'
def keyfn(x):
return int(x['Threads']),x['Expt'],int(x['ValSize']),int(x['Key/Read']),float(x['WriteFrac']),float(x['Zipf'])
aggfns=[lsum, mean, mean, mean]
valcols=('Throughput', 'R50', 'R99', 'Ravg')
allkeycols=('Threads','Expt','ValSize','Key/Read','WriteFrac','Zipf')
seriesColNum=[1,3]
assert(len(aggfns) == len(valcols))
def getSeries(key):
res=map(lambda x: str(key[x]),seriesColNum)
# print "key={} 0={} type={} res={}".format(key,key[0],type(key),res)
return "-".join(res);
def getTitle(key):
title=""
for k in range(1, len(allkeycols)): #Do not count Threads
if k not in seriesColNum:
title += "{} = {} ".format(allkeycols[k],key[k])
return title
def valfn(row):
return map(lambda x: int(row[x]), valcols)
def plotFig(data,title,colname):
fig,p=plt.subplots()
for x,y,l in data:
assert len(x)==nthreads,("Len x =",str(len(x)))
assert len(y)==nthreads
c = ('-o' if l.startswith("Eig") else '-x') if not l.startswith("Contr") else '-*'
p.plot(x, y, c,label=l)
plt.xlabel("NumThreads")
if(colname == "Throughput"):
plt.ylabel("Throughput (ops/s)")
else:
plt.ylabel("Latency (us)")
p.set_xscale('log', basex=2)
plt.legend()
plt.title("\n".join(wrap(title,60)))
plt.savefig(file[:-4]+"-"+colname+".png")
plt.clf()
data = list(csv.DictReader(open(file, 'r')))
groupedData = defaultdict(lambda : [])
for row in filter(filterfn,data):
groupedData[keyfn(row)].append(valfn(row))
aggData={}
for k,v in groupedData.iteritems():
aggData[k]= map(lambda x: x[0](x[1]), zip(aggfns,zip(*v)))
title=""
series=defaultdict(lambda: [])
for key in sorted(aggData.keys()):
s=getSeries(key)
if title=="":
title=getTitle(key)
vals = aggData[key]
vals.insert(0, nclients * key[0])
# print(" key = {} type = {} val = {} tval = {}".format(thr, type(thr), aggData[key], type(aggData[key])))
series[s].append(vals)
def normalize(a, b):
c= map(lambda x: x[0]/float(x[1]), zip(a,b))
print "A = {} B = {} C = {}".format(a,b,c)
return c
seriesTr = {}
base=[]
for s,d in series.iteritems():
seriesTr[s]=zip(*d)
if(s.startswith('Eiger')):
base=seriesTr[s]
assert(len(seriesTr[s]) == (len(valcols)+1))
for val in range(0, len(valcols)):
print valcols[val]+"::"
print "Title = "+title
# for s,d in seriesTr.iteritems():
# print "{} -> {} {}".format(s, d[0],d[val])
baseData = base[val+1]
# print "Base={} ".format(baseData)
ser_val = map(lambda x: (seriesTr[x][0], normalize(seriesTr[x][val+1], baseData) ,x+" "+valcols[val]),sorted(seriesTr.keys()))
plotFig(ser_val,title,valcols[val])
# for s in seriesNames:
# # map(keyfn, filter(lambda x: x['Expt']=='Eiger' and filterfn(x), data))
# # cops = map(keyfn,filter(lambda x: x['Expt']=='COPS-SNOW' and filterfn(x), data))
# # print "COPS = {}".format(len(cops))
# # print "Eiger = {}".format(len(eiger))
# for k in sorted(aggData):
# print "{} -> {}".format(k,aggData[k])