00001
00002
00003
00004 def get_max(data,index=1):
00005 max_score=-1
00006 for el in data:
00007 sec=el[index]
00008 if max_score<sec:
00009 max_score=sec
00010 return max_score
00011
00012 def get_min(data,index=1):
00013 min_score=1e20
00014 for el in data:
00015 sec=el[index]
00016 if min_score>sec:
00017 min_score=sec
00018 return min_score
00019
00020 def manipulate_log(outdir,logfile_name,secsperbin):
00021
00022 import time
00023 import sys
00024 import ROOT
00025
00026
00027
00028 data=[]
00029
00030
00031 logfile=open(logfile_name,'r')
00032 logfile_lines=logfile.readlines()
00033 logfile.close()
00034
00035
00036 i=0
00037 bench_number=0;
00038 while i < len(logfile_lines):
00039 line=logfile_lines[i]
00040
00041 if 'Composite Score:' in line:
00042 line=line[:-1]
00043 line_content_list=line.split()
00044
00045
00046 composite_score=float(line_content_list[2])
00047
00048 bench_number+=1
00049 data.append((bench_number,composite_score))
00050 i+=1
00051
00052
00053
00054
00055 __argv=sys.argv
00056 sys.argv=sys.argv[:1]
00057 ROOT.gROOT.SetStyle("Plain")
00058 sys.argv=__argv
00059
00060
00061
00062
00063
00064
00065 rootfilename='%s/graphs.root' %outdir
00066 myfile=ROOT.TFile(rootfilename,'RECREATE')
00067
00068
00069
00070 min_val=get_min(data,1)
00071 max_val=get_max(data,1)
00072 interval=int(max_val-min_val)
00073
00074 min_val=min_val-interval*0.2
00075 max_val=max_val+interval*0.2
00076 interval=int(max_val-min_val)
00077
00078 nbins=int(interval/secsperbin)
00079
00080 print 'Minval=',min_val,' maxval=',max_val, ' interval=',interval
00081
00082 histo=ROOT.TH1F('Composite Score(Mflops)','Composite Score (Mflops)',nbins,min_val,max_val)
00083 histo.GetXaxis().SetTitle("Mflops")
00084
00085 npoints=len(data)
00086
00087 graph=ROOT.TGraph(npoints)
00088 graph.SetMarkerStyle(8)
00089 graph.SetMarkerSize(.7)
00090 graph.SetMarkerColor(1)
00091 graph.SetLineWidth(3)
00092 graph.SetLineColor(2)
00093 graph.SetTitle('Composite Score')
00094 graph.SetName('Composite Score')
00095 graph.GetXaxis().SetTitle("Benchmark sequential number")
00096
00097 last_event=data[-1][0]
00098 print 'last event =',last_event
00099 graph.GetXaxis().SetLimits(0,last_event)
00100
00101 graph.GetYaxis().SetTitleOffset(1.3)
00102 graph.GetYaxis().SetTitle("Mflops")
00103 graph.GetYaxis().SetRangeUser(min_val,max_val)
00104
00105
00106
00107
00108
00109 evt_counter=0
00110 for bench_number,composite_score in data:
00111 graph.SetPoint(evt_counter,bench_number,composite_score)
00112 histo.Fill(composite_score)
00113 evt_counter+=1
00114
00115
00116 avg=histo.GetMean()
00117 avg_line=ROOT.TLine(1,avg,last_event,avg)
00118 avg_line.SetLineColor(4)
00119 avg_line.SetLineWidth(2)
00120
00121
00122 graph_canvas=ROOT.TCanvas('graph_canvas')
00123 graph_canvas.cd()
00124 graph.Draw("ALP")
00125 avg_line.Draw("Same")
00126
00127 graph_canvas.Print("%s/graph.gif" %outdir,"gif")
00128
00129
00130 graph.Write()
00131 graph_canvas.Write()
00132
00133 histo_canvas=ROOT.TCanvas('histo_canvas')
00134 histo_canvas.cd()
00135 histo.Draw('')
00136
00137 histo_canvas.Print("%s/histo.gif" %outdir,"gif")
00138
00139
00140 histo.Write()
00141 histo_canvas.Write()
00142
00143 myfile.Close()
00144
00145
00146
00147 titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
00148 %(os.environ['CMSSW_VERSION'],time.asctime())
00149
00150 html_file_name='%s/%s.html' %(outdir,logfile_name[:-4])
00151 html_file=open(html_file_name,'w')
00152 html_file.write('<html>\n<body>\n'+\
00153 titlestring)
00154 html_file.write('<table>\n'+\
00155 '<tr><td><img src=graph.gif></img></td></tr>'+\
00156 '<tr><td><img src=histo.gif></img></td></tr>'+\
00157 '</table>\n')
00158 html_file.write('\n</body>\n</html>')
00159 html_file.close()
00160
00161
00162
00163
00164 if __name__ == '__main__':
00165
00166 import optparse
00167 import os
00168
00169
00170 usage='cmsScimarkParser.py <options>'
00171 parser = optparse.OptionParser(usage)
00172 parser.add_option('-i', '--in_ profile',
00173 help='The profile to manipulate' ,
00174 default='',
00175 dest='profile')
00176
00177 parser.add_option('-o', '--outdir',
00178 help='The directory of the output' ,
00179 default='',
00180 dest='outdir')
00181
00182 parser.add_option('-n',
00183 help='Number of secs per bin. Default is 1.' ,
00184 default='1',
00185 dest='startevt')
00186
00187 (options,args) = parser.parse_args()
00188
00189
00190 if options.profile=='' or\
00191 options.outdir=='':
00192 raise('Please select a profile and an output dir!')
00193
00194 if not os.path.exists(options.profile) or\
00195 not os.path.exists(options.outdir):
00196 raise ('Outdir or input profile not present!')
00197
00198 try:
00199 startevt=float(options.startevt)
00200 except ValueError:
00201 print 'Problems in convertng starting event value!'
00202
00203
00204
00205 manipulate_log(options.outdir,options.profile,startevt)
00206
00207