File indexing completed on 2024-04-06 12:32:56
0001
0002
0003
0004 from __future__ import print_function
0005 def get_max(data,index=1):
0006 max_score=-1
0007 for el in data:
0008 sec=el[index]
0009 if max_score<sec:
0010 max_score=sec
0011 return max_score
0012
0013 def get_min(data,index=1):
0014 min_score=1e20
0015 for el in data:
0016 sec=el[index]
0017 if min_score>sec:
0018 min_score=sec
0019 return min_score
0020
0021 def manipulate_log(outdir,logfile_name,secsperbin):
0022
0023 import time
0024 import sys
0025 import ROOT
0026
0027
0028
0029 data=[]
0030
0031
0032 logfile=open(logfile_name,'r')
0033 logfile_lines=logfile.readlines()
0034 if not logfile_lines:
0035 print("The logfile %s is empty! Exiting now."%logfile_name)
0036 sys.exit()
0037 logfile.close()
0038
0039
0040 i=0
0041 bench_number=0;
0042 while i < len(logfile_lines):
0043 line=logfile_lines[i]
0044
0045 if 'Composite Score:' in line:
0046 line=line[:-1]
0047 line_content_list=line.split()
0048
0049
0050 composite_score=float(line_content_list[2])
0051
0052 bench_number+=1
0053 data.append((bench_number,composite_score))
0054 i+=1
0055
0056
0057
0058
0059 __argv=sys.argv
0060 sys.argv=sys.argv[:1]
0061 ROOT.gROOT.SetStyle("Plain")
0062 sys.argv=__argv
0063
0064
0065
0066
0067
0068
0069 rootfilename='%s/graphs.root' %outdir
0070 myfile=ROOT.TFile(rootfilename,'RECREATE')
0071
0072
0073
0074 min_val=get_min(data,1)
0075 max_val=get_max(data,1)
0076 interval=int(max_val-min_val)
0077
0078 min_val=min_val-interval*0.2
0079 max_val=max_val+interval*0.2
0080 interval=int(max_val-min_val)
0081
0082 nbins=int(interval/secsperbin)
0083
0084 print('Minval=',min_val,' maxval=',max_val, ' interval=',interval)
0085
0086 histo=ROOT.TH1F('Composite Score(Mflops)','Composite Score (Mflops)',nbins,min_val,max_val)
0087 histo.GetXaxis().SetTitle("Mflops")
0088
0089 npoints=len(data)
0090
0091 graph=ROOT.TGraph(npoints)
0092 graph.SetMarkerStyle(8)
0093 graph.SetMarkerSize(.7)
0094 graph.SetMarkerColor(1)
0095 graph.SetLineWidth(3)
0096 graph.SetLineColor(2)
0097 graph.SetTitle('Composite Score')
0098 graph.SetName('Composite Score')
0099 graph.GetXaxis().SetTitle("Benchmark sequential number")
0100
0101 last_event=data[-1][0]
0102 print('last event =',last_event)
0103 graph.GetXaxis().SetLimits(0,last_event)
0104
0105 graph.GetYaxis().SetTitleOffset(1.3)
0106 graph.GetYaxis().SetTitle("Mflops")
0107 graph.GetYaxis().SetRangeUser(min_val,max_val)
0108
0109
0110
0111
0112
0113 evt_counter=0
0114 for bench_number,composite_score in data:
0115 graph.SetPoint(evt_counter,bench_number,composite_score)
0116 histo.Fill(composite_score)
0117 evt_counter+=1
0118
0119
0120 avg=histo.GetMean()
0121 avg_line=ROOT.TLine(1,avg,last_event,avg)
0122 avg_line.SetLineColor(4)
0123 avg_line.SetLineWidth(2)
0124
0125
0126 graph_canvas=ROOT.TCanvas('graph_canvas')
0127 graph_canvas.cd()
0128 graph.Draw("ALP")
0129 avg_line.Draw("Same")
0130
0131 graph_canvas.Print("%s/graph.png" %outdir,"png")
0132
0133
0134 graph.Write()
0135 graph_canvas.Write()
0136
0137 histo_canvas=ROOT.TCanvas('histo_canvas')
0138 histo_canvas.cd()
0139 histo.Draw('')
0140
0141 histo_canvas.Print("%s/histo.png" %outdir,"png")
0142
0143
0144 histo.Write()
0145 histo_canvas.Write()
0146
0147 myfile.Close()
0148
0149
0150
0151 titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
0152 %(os.environ['CMSSW_VERSION'],time.asctime())
0153
0154 html_file_name='%s/%s.html' %(outdir,logfile_name[:-4])
0155 html_file=open(html_file_name,'w')
0156 html_file.write('<html>\n<body>\n'+\
0157 titlestring)
0158 html_file.write('<table>\n'+\
0159 '<tr><td><img src=graph.png></img></td></tr>'+\
0160 '<tr><td><img src=histo.png></img></td></tr>'+\
0161 '</table>\n')
0162 html_file.write('\n</body>\n</html>')
0163 html_file.close()
0164
0165
0166
0167
0168 if __name__ == '__main__':
0169
0170 import optparse
0171 import os
0172
0173
0174 usage='cmsScimarkParser.py <options>'
0175 parser = optparse.OptionParser(usage)
0176 parser.add_option('-i', '--in_ profile',
0177 help='The profile to manipulate' ,
0178 default='',
0179 dest='profile')
0180
0181 parser.add_option('-o', '--outdir',
0182 help='The directory of the output' ,
0183 default='',
0184 dest='outdir')
0185
0186 parser.add_option('-n',
0187 help='Number of secs per bin. Default is 1.' ,
0188 default='1',
0189 dest='startevt')
0190
0191 (options,args) = parser.parse_args()
0192
0193
0194 if options.profile=='' or\
0195 options.outdir=='':
0196 raise('Please select a profile and an output dir!')
0197
0198 if not os.path.exists(options.profile) or\
0199 not os.path.exists(options.outdir):
0200 raise ('Outdir or input profile not present!')
0201
0202 try:
0203 startevt=float(options.startevt)
0204 except ValueError:
0205 print('Problems in convertng starting event value!')
0206
0207
0208
0209 manipulate_log(options.outdir,options.profile,startevt)
0210
0211