31 logfile=open(logfile_name,
'r')
32 logfile_lines=logfile.readlines()
37 while i < len(logfile_lines):
39 if 'TimeEvent>' in line:
41 line_content_list=line.split(
' ')
42 event_number=int(line_content_list[1])
43 seconds=float(line_content_list[3])
44 data.append((event_number,seconds))
52 ROOT.gROOT.SetStyle(
"Plain")
57 ROOT.gROOT.SetBatch(1)
60 rootfilename=
'%s/graphs.root' %outdir
61 myfile=ROOT.TFile(rootfilename,
'RECREATE')
67 interval=max_val-min_val
69 min_val=min_val-interval*0.2
70 max_val=max_val+interval*0.2
71 interval=max_val-min_val
73 nbins=int(interval/secsperbin)
75 print 'Minval=',min_val,
' maxval=',max_val,
' interval=',interval
77 histo=ROOT.TH1F(
'Seconds per event',
'Seconds per event',nbins,min_val,max_val)
78 histo.GetXaxis().SetTitle(
"s")
82 graph=ROOT.TGraph(npoints)
83 graph.SetMarkerStyle(8)
84 graph.SetMarkerSize(.7)
85 graph.SetMarkerColor(1)
88 graph.SetTitle(
'Seconds per event')
89 graph.SetName(
'SecondsPerEvent')
90 graph.GetXaxis().SetTitle(
"Event")
92 last_event=data[-1][0]
93 print 'last event =',last_event
94 graph.GetXaxis().SetLimits(0,last_event)
96 graph.GetYaxis().SetTitleOffset(1.3)
97 graph.GetYaxis().SetTitle(
"s")
98 graph.GetYaxis().SetRangeUser(0,max_val)
106 for evt_num,secs
in data:
107 graph.SetPoint(evt_counter,evt_num,secs)
112 print 'Total Time=', total
116 avg_line=ROOT.TLine(1,avg,last_event,avg)
117 avg_line.SetLineColor(4)
118 avg_line.SetLineWidth(2)
121 graph_canvas=ROOT.TCanvas(
'graph_canvas')
124 avg_line.Draw(
"Same")
126 graph_canvas.Print(
"%s/graph.gif" %outdir,
"gif")
132 histo_canvas=ROOT.TCanvas(
'histo_canvas')
136 histo_canvas.Print(
"%s/histo.gif" %outdir,
"gif")
146 titlestring=
'<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
147 %(os.environ[
'CMSSW_VERSION'],time.asctime())
149 html_file_name=
'%s/%s.html' %(outdir,logfile_name[:-4])
150 html_file=open(html_file_name,
'w')
151 html_file.write(
'<html>\n<body>\n'+\
153 html_file.write(
'<table>\n'+\
154 '<tr><td><img src=graph.gif></img></td></tr>'+\
155 '<tr><td><img src=histo.gif></img></td></tr>'+\
157 html_file.write(
'\n</body>\n</html>')
163 if __name__ ==
'__main__':
169 usage=
'timing_parser.py <options>'
170 parser = optparse.OptionParser(usage)
171 parser.add_option(
'-i',
'--in_ profile',
172 help=
'The profile to manipulate' ,
176 parser.add_option(
'-o',
'--outdir',
177 help=
'The directory of the output' ,
181 parser.add_option(
'-n',
182 help=
'Number of secs per bin. Default is 1.' ,
186 (options,args) = parser.parse_args()
189 if options.profile==
'' or\
191 raise(
'Please select a profile and an output dir!')
193 if not os.path.exists(options.profile)
or\
194 not os.path.exists(options.outdir):
195 raise (
'Outdir or input profile not present!')
198 startevt=float(options.startevt)
200 print 'Problems in convertng starting event value!'