15 values_set=(
'vsize',
'delta_vsize',
'rss',
'delta_rss')
19 logfile=open(logfile_name,
'r')
20 logfile_lines=logfile.readlines()
27 while i < len(logfile_lines):
29 if '%MSG-w MemoryCheck:' in line:
31 line_content_list=line.split(
' ')
32 event_number=int(line_content_list[-1])
33 if event_number<startevt:
39 line_content_list=line.split(
' ')
40 vsize=float(line_content_list[4])
41 delta_vsize=float(line_content_list[5])
42 rss=float(line_content_list[7])
43 delta_rss=float(line_content_list[8])
45 data.append((event_number,{
'vsize':vsize,
46 'delta_vsize':delta_vsize,
48 'delta_rss':delta_rss}))
51 max_rss=(event_number, rss)
54 elif parse_report
and 'MemoryReport' in line:
55 while 'TimeReport' not in line:
56 report += line.replace(
'MemoryReport',
'')
58 line = logfile_lines[i]
63 print 'Maximum rss =', max_rss[1]
69 if data[0][0]==data[1][0]:
70 print 'Two modules seem to have some output.\nCollapsing ...'
76 new_eventnumber=dataline1[0]
77 new_vsize=dataline2[1][
'vsize']
78 new_delta_vsize=dataline1[1][
'delta_vsize']+dataline2[1][
'delta_vsize']
79 new_rss=dataline2[1][
'rss']
80 new_delta_rss=dataline1[1][
'delta_rss']+dataline2[1][
'delta_rss']
82 new_data.append((new_eventnumber,{
'vsize':new_vsize,
83 'delta_vsize':new_delta_vsize,
85 'delta_rss':new_delta_rss}))
87 if i==len(data):
break
90 print 'Collapsing: Done!'
94 print '%s values read and stored ...' %npoints
100 ROOT.gROOT.SetStyle(
"Plain")
106 ROOT.gROOT.SetBatch(1)
109 rootfilename=
'%s/graphs.root' %outdir
110 myfile=ROOT.TFile(rootfilename,
'RECREATE')
114 for value
in values_set:
116 graph=ROOT.TGraph(npoints)
117 graph.SetMarkerStyle(8)
118 graph.SetMarkerSize(.7)
119 graph.SetMarkerColor(1)
120 graph.SetLineWidth(3)
121 graph.SetLineColor(2)
122 graph.SetTitle(value)
123 graph.SetName(
'%s_graph' %value)
128 for event_number,vals_dict
in data:
129 graph.SetPoint(point_counter,
134 graph.GetXaxis().SetTitle(
"Event")
135 last_event=data[-1][0]
136 graph.GetXaxis().SetRangeUser(0,last_event+1)
137 graph.GetYaxis().SetTitleOffset(1.3)
138 graph.GetYaxis().SetTitle(
"MB")
143 mycanvas=ROOT.TCanvas(
'%s_canvas' %value)
147 mycanvas.Print(
"%s/%s_graph.png"%(outdir,value),
"png")
159 titlestring=
'<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
160 %(os.environ[
'CMSSW_VERSION'],time.asctime())
164 if len(logfile_name)>16
and 'TimingReport.log' in logfile_name[-16:]:
165 file_name=logfile_name[:-16]+
"_SimpleMemReport"
167 file_name=logfile_name[:-4]+
"_SimpleMemReport"
168 html_file_name=
'%s/%s.html' %(outdir,file_name)
169 html_file=open(html_file_name,
'w')
170 html_file.write(
'<html>\n<body>\n'+\
172 html_file.write(
'<table>\n'+\
173 '<tr>\n<td><img src=vsize_graph.png></img></td>\n'+\
174 '<td><img src=rss_graph.png></img></td>\n</tr>\n'+\
175 '<tr>\n<td><img src=delta_vsize_graph.png></img></td>\n'+\
176 '<td><img src=delta_rss_graph.png></img></td>\n</tr>\n' +\
178 html_file.write(
'<hr>\n<h1>Memory Checker Report</h1>\n<pre>\n' + report +
'</pre>')
179 html_file.write(
'\n</body>\n</html>')
185 if __name__ ==
'__main__':
191 usage=
'simplememchecker_parser.py <options>'
192 parser = optparse.OptionParser(usage)
193 parser.add_option(
'-i',
'--in_ profile',
194 help=
'The profile to manipulate' ,
198 parser.add_option(
'-o',
'--outdir',
199 help=
'The directory of the output' ,
203 parser.add_option(
'-n',
204 help=
'The event number from which we start. Default is 1.' ,
208 (options,args) = parser.parse_args()
211 if options.profile==
'' or\
213 raise(
'Please select a profile and an output dir!')
215 if not os.path.exists(options.profile)
or\
216 not os.path.exists(options.outdir):
217 raise (
'Outdir or input profile not present!')
220 startevt=int(options.startevt)
222 print 'Problems in convertng starting event value!'