-
Notifications
You must be signed in to change notification settings - Fork 0
/
ts_plot.py
executable file
·72 lines (68 loc) · 2.9 KB
/
ts_plot.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
#!/usr/bin/env python3
import numpy as np
import pandas as pd
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
def plotter(ax,data,label,color,alpha,column,mask=False):
length=np.array(list(map(float,data['N'])))
col_data=np.array(list(map(float,data[column])))
exit_status=np.array(list(map(float,data['exit_status'])))
if mask:
mask=(length>=14)&(length<=14)
else:
mask=length>=-1
ax.plot(length[mask],col_data[mask],linestyle='--',linewidth=0.5,color=color,zorder=0)
neomask=mask&(exit_status==0)
if label:
ax.scatter(length[neomask],col_data[neomask],marker='+',label=label,color=color,alpha=alpha,zorder=1)
else:
ax.scatter(length[neomask],col_data[neomask],marker='+',color=color,alpha=alpha,zorder=1)
if np.sum(exit_status)>0:
neomask=mask&(exit_status==1)
ax.scatter(length[neomask],col_data[neomask],marker='x',color=color,alpha=alpha,zorder=1)
def runner(data,column):
inset=plt.axes(label=column).inset_axes([0.3,0.25,0.05,0.7])
unit=''
if column=='compile_time':
unit='(s)'
elif column=='memory_use':
unit='(kb)'
plt.title('length vs. {}{}'.format(column,unit))
tvars=['int8_t','uint8_t','int16_t','uint16_t','int32_t','uint32_t','int64_t','uint64_t']
cvars=['int32_t','uint32_t','float','int64_t','uint64_t','double','long double']
alpha=0.0
dalpha=1.0/(len(tvars)*len(cvars)+1)
for tvar in tvars:
for cvar in cvars:
tvar_filter=data['tvar'].str.match(tvar)
cvar_filter=data['cvar'].str.match(cvar)
gcc_filter=data['compiler'].str.match('g\+\+')
gcc_selection=data[gcc_filter & tvar_filter & cvar_filter]
alpha=alpha+dalpha
plotter(plt,gcc_selection,'g++<'+tvar+','+cvar+'>','blue',alpha,column)
#plotter(inset,gcc_selection,False,'blue',alpha,column,mask=True)
alpha=0.0
for tvar in tvars:
for cvar in cvars:
tvar_filter=data['tvar'].str.match(tvar)
cvar_filter=data['cvar'].str.match(cvar)
clang_filter=data['compiler'].str.match('clang\+\+')
clang_selection=data[clang_filter & tvar_filter & cvar_filter]
alpha=alpha+dalpha
plotter(plt,clang_selection,'clang++<'+tvar+','+cvar+'>','green',alpha,column)
plotter(inset,clang_selection,False,'green',alpha,column,mask=True)
plt.xlim((0,16))
inset.autoscale(axis='y',tight=True)
inset.set_xticks([14])
if(column=='compile_time'):
plt.yscale('log')
plt.ylim((0.1,None))
plt.legend(loc='best',prop={'size':1.5})
plt.tight_layout()
plt.savefig('ts_'+column+'.png')
plt.savefig('ts_'+column+'.pdf')
data=pd.read_csv('ts_compile.ls',quotechar='"',delimiter=';',names=['compiler','N','tvar','cvar','compile_time','memory_use','exit_status'])
runner(data,'compile_time')
plt.clf()
runner(data,'memory_use')