15 values_set=(
'vsize',
'delta_vsize',
'rss',
'delta_rss')
18 logfile=open(logfile_name,
'r')
19 logfile_lines=logfile.readlines()
24 while i < len(logfile_lines):
26 if '%MSG-w MemoryCheck:' in line:
28 line_content_list=line.split(
' ')
29 event_number=int(line_content_list[-1])
30 if event_number<startevt:
36 line_content_list=line.split(
' ')
37 vsize=float(line_content_list[4])
38 delta_vsize=float(line_content_list[5])
39 rss=float(line_content_list[7])
40 delta_rss=float(line_content_list[8])
42 data.append((event_number,{
'vsize':vsize,
43 'delta_vsize':delta_vsize,
45 'delta_rss':delta_rss}))
52 if data[0][0]==data[1][0]:
53 print 'Two modules seem to have some output.\nCollapsing ...'
59 new_eventnumber=dataline1[0]
60 new_vsize=dataline2[1][
'vsize']
61 new_delta_vsize=dataline1[1][
'delta_vsize']+dataline2[1][
'delta_vsize']
62 new_rss=dataline2[1][
'rss']
63 new_delta_rss=dataline1[1][
'delta_rss']+dataline2[1][
'delta_rss']
65 new_data.append((new_eventnumber,{
'vsize':new_vsize,
66 'delta_vsize':new_delta_vsize,
68 'delta_rss':new_delta_rss}))
70 if i==len(data):
break
73 print 'Collapsing: Done!'
77 print '%s values read and stored ...' %npoints
83 ROOT.gROOT.SetStyle(
"Plain")
89 ROOT.gROOT.SetBatch(1)
92 rootfilename=
'%s/graphs.root' %outdir
93 myfile=ROOT.TFile(rootfilename,
'RECREATE')
97 for value
in values_set:
99 graph=ROOT.TGraph(npoints)
100 graph.SetMarkerStyle(8)
101 graph.SetMarkerSize(.7)
102 graph.SetMarkerColor(1)
103 graph.SetLineWidth(3)
104 graph.SetLineColor(2)
105 graph.SetTitle(value)
106 graph.SetName(
'%s_graph' %value)
111 for event_number,vals_dict
in data:
112 graph.SetPoint(point_counter,
117 graph.GetXaxis().SetTitle(
"Event")
118 last_event=data[-1][0]
119 graph.GetXaxis().SetRangeUser(0,last_event+1)
120 graph.GetYaxis().SetTitleOffset(1.3)
121 graph.GetYaxis().SetTitle(
"MB")
126 mycanvas=ROOT.TCanvas(
'%s_canvas' %value)
130 mycanvas.Print(
"%s/%s_graph.gif"%(outdir,value),
"gif")
142 titlestring=
'<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
143 %(os.environ[
'CMSSW_VERSION'],time.asctime())
147 if len(logfile_name)>16
and 'TimingReport.log' in logfile_name[-16:]:
148 file_name=logfile_name[:-16]+
"_SimpleMemReport"
150 file_name=logfile_name[:-4]+
"_SimpleMemReport"
151 html_file_name=
'%s/%s.html' %(outdir,file_name)
152 html_file=open(html_file_name,
'w')
153 html_file.write(
'<html>\n<body>\n'+\
155 html_file.write(
'<table>\n'+\
156 '<tr><td><img src=vsize_graph.gif></img></td>'+\
157 '<td><img src=rss_graph.gif></img></td></tr>'+\
158 '<tr><td><img src=delta_vsize_graph.gif></img></td>'+\
159 '<td><img src=delta_rss_graph.gif></img></td></tr>' +\
162 html_file.write(
'\n</body>\n</html>')
168 if __name__ ==
'__main__':
174 usage=
'simplememchecker_parser.py <options>'
175 parser = optparse.OptionParser(usage)
176 parser.add_option(
'-i',
'--in_ profile',
177 help=
'The profile to manipulate' ,
181 parser.add_option(
'-o',
'--outdir',
182 help=
'The directory of the output' ,
186 parser.add_option(
'-n',
187 help=
'The event number from which we start. Default is 1.' ,
191 (options,args) = parser.parse_args()
194 if options.profile==
'' or\
196 raise(
'Please select a profile and an output dir!')
198 if not os.path.exists(options.profile)
or\
199 not os.path.exists(options.outdir):
200 raise (
'Outdir or input profile not present!')
203 startevt=int(options.startevt)
205 print 'Problems in convertng starting event value!'