Created
November 30, 2020 21:09
-
-
Save kpedro88/69f57f41bf1ce81f33a1bed1df1dff84 to your computer and use it in GitHub Desktop.
Phase 2 CPU usage plot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files = dict( | |
D41 = [ | |
["cl_compare_cpu_11_0_0Pre1vsPre2___.txt",["11_0_0_pre1","11_0_0_pre2"]], | |
["cl_compare_cpu_11_0_0Pre2vsPre3.txt",["11_0_0_pre3"]], | |
["cl_compare_cpu_11_0_0Pre3vsPre4.txt",["11_0_0_pre4"]], | |
["cl_compare_cpu_11_0_0Pre4vsPre5.txt",["11_0_0_pre5"]], | |
# ["cl_compare_cpu_11_0_0Pre5vsPre6.txt",["11_0_0_pre6"]], # bug | |
["cl_compare_cpu_11_0_0Pre6vsPre7.txt",["11_0_0_pre7"]], | |
["cl_compare_cpu_11_0_0Pre7vsPre8.txt",["11_0_0_pre8"]], | |
["cl_compare_cpu_11_0_0Pre8vsPre9.txt",["11_0_0_pre9"]], | |
["cl_compare_cpu_11_0_0Pre9vsPre10.txt",["11_0_0_pre10"]], | |
["cl_compare_cpu_11_0_0Pre10vsPre11.txt",["11_0_0_pre11"]], | |
["cl_compare_cpu_11_0_0Pre11vsPre12.txt",["11_0_0_pre12"]], | |
["cl_compare_cpu_11_0_0Pre12vsPre13.txt",["11_0_0_pre13"]], | |
["cl_compare_cpu_11_0_0Pre13vs11_0_0.txt",["11_0_0"]], | |
["cl_compare_cpu_11_1_0Pre1vsPre2.txt",["11_1_0_pre1","11_1_0_pre2"]], | |
["cl_compare_cpu_11_1_0Pre2vsPre3.txt",["11_1_0_pre3"]], | |
["cl_compare_cpu_11_1_0Pre3vsPre4.txt",["11_1_0_pre4"]], | |
["cl_compare_cpu_11_1_0Pre4vsPre5.txt",["11_1_0_pre5"]], | |
["cl_compare_cpu_11_1_0Pre5vsPre6.txt",["11_1_0_pre6"]], | |
["cl_compare_cpu_11_1_0Pre6vsPre7.txt",["11_1_0_pre7"]], | |
["cl_compare_cpu_11_1_0Pre7vsPre8.txt",["11_1_0_pre8"]], | |
["cl_compare_cpu_11_1_0Pre8vsfull.txt",["11_1_0"]], | |
["cl_compare_cpu_11_2_0Pre1vsPre2.txt",["11_2_0_pre1","11_2_0_pre2"]], | |
], | |
D49 = [ | |
["cl_compare_cpu_11_1_0d41vsd49.txt",["11_1_0"]], | |
["cl_compare_cpu_11_2_0Pre2_d41vsd49.txt",["11_2_0_pre2"]], | |
["cl_compare_cpu_11_2_0Pre2vsPre3.txt",["11_2_0_pre3"]], | |
["cl_compare_cpu_11_2_0Pre3vsPre4.txt",["11_2_0_pre4"]], | |
["cl_compare_cpu_11_2_0Pre4vsPre5.txt",["11_2_0_pre5"]], | |
["cl_compare_cpu_11_2_0Pre5vsPre6.txt",["11_2_0_pre6"]], | |
["cl_compare_cpu_11_2_0Pre5vsPre6.txt",["11_2_0_pre6"]], | |
["cl_compare_cpu_11_2_0Pre6vsPre7.txt",["11_2_0_pre7"]], | |
] | |
) | |
nevents = 100 | |
for key,flist in files.iteritems(): | |
release = [] | |
total = [] | |
output = [] | |
adjusted = [] | |
for file in flist: | |
fname = file[0] | |
fdata = file[1] | |
with open("/cygdrive/c/Temp/cpu_compare/"+fname,'r') as infile: | |
release.extend(fdata) | |
for line in infile: | |
matches = [m in line for m in ["edm::PoolOutputModule::write","Total Cumulative"]] | |
if not any(matches): continue | |
linesplit = line.split() | |
# get pre | |
if len(fdata)==2: | |
if matches[0]: output.append(float(linesplit[8][1:])/nevents) | |
elif matches[1]: | |
total.append(float(linesplit[3])/nevents) | |
adjusted.append(total[-1]-output[-1]) | |
# get post | |
if matches[0]: output.append(float(linesplit[10])/nevents) | |
elif matches[1]: | |
total.append(float(linesplit[5])/nevents) | |
adjusted.append(total[-1]-output[-1]) | |
with open("cpu_compare_data_{}.txt".format(key),'w') as outfile: | |
for line in zip(release,total,output,adjusted): | |
outfile.write(' '.join(str(x) for x in line)+'\n') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib as mpl | |
mpl.use('Agg') | |
import matplotlib.pyplot as plt | |
dataD41 = np.loadtxt("cpu_compare_data_D41.txt", dtype={'names': ('release','total','output','adjusted'), 'formats': ('O','f4','f4','f4')}) | |
dataD49 = np.loadtxt("cpu_compare_data_D49.txt", dtype={'names': ('release','total','output','adjusted'), 'formats': ('O','f4','f4','f4')}) | |
markers = ['.','d'] | |
lines = ['-',':'] | |
data = [dataD41, dataD49] | |
# make x-axis | |
xvals = list(dataD41['release']) | |
for x in dataD49['release']: | |
if x not in xvals: xvals.append(x) | |
convert_HS06 = 18*3.7/2.1 | |
fig, ax = plt.subplots(1) | |
for di,dataD in enumerate(data): | |
ax.set_prop_cycle(None) | |
for qty in ['total','output','adjusted']: | |
ax.plot(dataD['release'],dataD[qty]*convert_HS06,label=qty,marker=markers[di],linestyle=lines[di]) | |
# for label in ax.get_xmajorticklabels(): | |
# label.set_rotation(70) | |
ax.set_ylabel("CPU/event [HS06]") | |
ax.set_xlabel("release") | |
if di==0: ax.legend(loc='best') | |
ax.set_xticklabels(xvals,rotation=70,ha='right') | |
fig.subplots_adjust(top=.95,right=.95,bottom=0.30) | |
fig.savefig("plot_cpu_compare2.png",**{"dpi":100}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment