16 values_set=(
'vsize',
'delta_vsize',
'rss',
'delta_rss')
20 logfile=open(logfile_name,
'r')
21 logfile_lines=logfile.readlines()
28 while i < len(logfile_lines):
30 if '%MSG-w MemoryCheck:' in line:
32 line_content_list=line.split(
' ')
33 event_number=
int(line_content_list[-1])
34 if event_number<startevt:
40 line_content_list=line.split(
' ')
41 vsize=
float(line_content_list[4])
42 delta_vsize=
float(line_content_list[5])
43 rss=
float(line_content_list[7])
44 delta_rss=
float(line_content_list[8])
46 data.append((event_number,{
'vsize':vsize,
47 'delta_vsize':delta_vsize,
49 'delta_rss':delta_rss}))
52 max_rss=(event_number, rss)
55 elif parse_report
and 'MemoryReport' in line:
56 while 'TimeReport' not in line:
57 report += line.replace(
'MemoryReport',
'')
59 line = logfile_lines[i]
64 print(
'Maximum rss =', max_rss[1])
70 if data[0][0]==data[1][0]:
71 print(
'Two modules seem to have some output.\nCollapsing ...')
77 new_eventnumber=dataline1[0]
78 new_vsize=dataline2[1][
'vsize']
79 new_delta_vsize=dataline1[1][
'delta_vsize']+dataline2[1][
'delta_vsize']
80 new_rss=dataline2[1][
'rss']
81 new_delta_rss=dataline1[1][
'delta_rss']+dataline2[1][
'delta_rss']
83 new_data.append((new_eventnumber,{
'vsize':new_vsize,
84 'delta_vsize':new_delta_vsize,
86 'delta_rss':new_delta_rss}))
88 if i==len(data):
break
91 print(
'Collapsing: Done!')
95 print(
'%s values read and stored ...' %npoints)
100 sys.argv=sys.argv[:1]
101 ROOT.gROOT.SetStyle(
"Plain")
107 ROOT.gROOT.SetBatch(1)
110 rootfilename=
'%s/graphs.root' %outdir
111 myfile=ROOT.TFile(rootfilename,
'RECREATE')
115 for value
in values_set:
117 graph=ROOT.TGraph(npoints)
118 graph.SetMarkerStyle(8)
119 graph.SetMarkerSize(.7)
120 graph.SetMarkerColor(1)
121 graph.SetLineWidth(3)
122 graph.SetLineColor(2)
123 graph.SetTitle(value)
124 graph.SetName(
'%s_graph' %value)
129 for event_number,vals_dict
in data:
130 graph.SetPoint(point_counter,
135 graph.GetXaxis().SetTitle(
"Event")
136 last_event=data[-1][0]
137 graph.GetXaxis().SetRangeUser(0,last_event+1)
138 graph.GetYaxis().SetTitleOffset(1.3)
139 graph.GetYaxis().SetTitle(
"MB")
144 mycanvas=ROOT.TCanvas(
'%s_canvas' %value)
148 mycanvas.Print(
"%s/%s_graph.png"%(outdir,value),
"png")
160 titlestring=
'<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
161 %(os.environ[
'CMSSW_VERSION'],time.asctime())
165 if len(logfile_name)>16
and 'TimingReport.log' in logfile_name[-16:]:
166 file_name=logfile_name[:-16]+
"_SimpleMemReport"
168 file_name=logfile_name[:-4]+
"_SimpleMemReport"
169 html_file_name=
'%s/%s.html' %(outdir,file_name)
170 html_file=open(html_file_name,
'w')
171 html_file.write(
'<html>\n<body>\n'+\
173 html_file.write(
'<table>\n'+\
174 '<tr>\n<td><img src=vsize_graph.png></img></td>\n'+\
175 '<td><img src=rss_graph.png></img></td>\n</tr>\n'+\
176 '<tr>\n<td><img src=delta_vsize_graph.png></img></td>\n'+\
177 '<td><img src=delta_rss_graph.png></img></td>\n</tr>\n' +\
179 html_file.write(
'<hr>\n<h1>Memory Checker Report</h1>\n<pre>\n' + report +
'</pre>')
180 html_file.write(
'\n</body>\n</html>')