17 values_set=(
'vsize',
'delta_vsize',
'rss',
'delta_rss')
21 logfile=open(logfile_name,
'r')
22 logfile_lines=logfile.readlines()
29 while i < len(logfile_lines):
31 if '%MSG-w MemoryCheck:' in line:
33 line_content_list=line.split(
' ')
34 event_number=int(line_content_list[-1])
35 if event_number<startevt:
41 line_content_list=line.split(
' ')
42 vsize=float(line_content_list[4])
43 delta_vsize=float(line_content_list[5])
44 rss=float(line_content_list[7])
45 delta_rss=float(line_content_list[8])
47 data.append((event_number,{
'vsize':vsize,
48 'delta_vsize':delta_vsize,
50 'delta_rss':delta_rss}))
53 max_rss=(event_number, rss)
56 elif parse_report
and 'MemoryReport' in line:
57 while 'TimeReport' not in line:
58 report += line.replace(
'MemoryReport',
'')
60 line = logfile_lines[i]
65 print(
'Maximum rss =', max_rss[1])
71 if data[0][0]==data[1][0]:
72 print(
'Two modules seem to have some output.\nCollapsing ...')
78 new_eventnumber=dataline1[0]
79 new_vsize=dataline2[1][
'vsize']
80 new_delta_vsize=dataline1[1][
'delta_vsize']+dataline2[1][
'delta_vsize']
81 new_rss=dataline2[1][
'rss']
82 new_delta_rss=dataline1[1][
'delta_rss']+dataline2[1][
'delta_rss']
84 new_data.append((new_eventnumber,{
'vsize':new_vsize,
85 'delta_vsize':new_delta_vsize,
87 'delta_rss':new_delta_rss}))
89 if i==len(data):
break
92 print(
'Collapsing: Done!')
96 print(
'%s values read and stored ...' %npoints)
101 sys.argv=sys.argv[:1]
102 ROOT.gROOT.SetStyle(
"Plain")
108 ROOT.gROOT.SetBatch(1)
111 rootfilename=
'%s/graphs.root' %outdir
112 myfile=ROOT.TFile(rootfilename,
'RECREATE')
116 for value
in values_set:
118 graph=ROOT.TGraph(npoints)
119 graph.SetMarkerStyle(8)
120 graph.SetMarkerSize(.7)
121 graph.SetMarkerColor(1)
122 graph.SetLineWidth(3)
123 graph.SetLineColor(2)
124 graph.SetTitle(value)
125 graph.SetName(
'%s_graph' %value)
130 for event_number,vals_dict
in data:
131 graph.SetPoint(point_counter,
136 graph.GetXaxis().SetTitle(
"Event")
137 last_event=data[-1][0]
138 graph.GetXaxis().SetRangeUser(0,last_event+1)
139 graph.GetYaxis().SetTitleOffset(1.3)
140 graph.GetYaxis().SetTitle(
"MB")
145 mycanvas=ROOT.TCanvas(
'%s_canvas' %value)
149 mycanvas.Print(
"%s/%s_graph.png"%(outdir,value),
"png")
161 titlestring=
'<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
162 %(os.environ[
'CMSSW_VERSION'],time.asctime())
166 if len(logfile_name)>16
and 'TimingReport.log' in logfile_name[-16:]:
167 file_name=logfile_name[:-16]+
"_SimpleMemReport"
169 file_name=logfile_name[:-4]+
"_SimpleMemReport"
170 html_file_name=
'%s/%s.html' %(outdir,file_name)
171 html_file=open(html_file_name,
'w')
172 html_file.write(
'<html>\n<body>\n'+\
174 html_file.write(
'<table>\n'+\
175 '<tr>\n<td><img src=vsize_graph.png></img></td>\n'+\
176 '<td><img src=rss_graph.png></img></td>\n</tr>\n'+\
177 '<tr>\n<td><img src=delta_vsize_graph.png></img></td>\n'+\
178 '<td><img src=delta_rss_graph.png></img></td>\n</tr>\n' +\
180 html_file.write(
'<hr>\n<h1>Memory Checker Report</h1>\n<pre>\n' + report +
'</pre>')
181 html_file.write(
'\n</body>\n</html>')