![]() |
![]() |
Functions | |
def | manipulate_log |
Variables | |
string | default = '' |
string | dest = 'profile' |
string | help = 'The profile to manipulate' |
tuple | parser = optparse.OptionParser(usage) |
tuple | startevt = int(options.startevt) |
string | usage = 'simplememchecker_parser.py <options>' |
def cmsSimplememchecker_parser::manipulate_log | ( | outdir, | ||
logfile_name, | ||||
startevt | ||||
) |
Definition at line 4 of file cmsSimplememchecker_parser.py.
00004 : 00005 00006 import time 00007 import sys 00008 import ROOT 00009 00010 os.system('pwd') 00011 00012 # the fundamental structure: the key is the evt number the value is a list containing 00013 # VSIZE deltaVSIZE RSS deltaRSS 00014 data=[] 00015 values_set=('vsize','delta_vsize','rss','delta_rss') 00016 00017 # open file and read it and fill the structure! 00018 logfile=open(logfile_name,'r') 00019 logfile_lines=logfile.readlines() 00020 logfile.close() 00021 00022 # we get the info we need! 00023 i=0 00024 while i < len(logfile_lines): 00025 line=logfile_lines[i] 00026 if '%MSG-w MemoryCheck:' in line: 00027 line=line[:-1] #no \n! 00028 line_content_list=line.split(' ') 00029 event_number=int(line_content_list[-1]) 00030 if event_number<startevt: 00031 i+=1 00032 continue 00033 i+=1 # we inspect the following line 00034 line=logfile_lines[i] 00035 line=line[:-1] #no \n! 00036 line_content_list=line.split(' ') 00037 vsize=float(line_content_list[4]) 00038 delta_vsize=float(line_content_list[5]) 00039 rss=float(line_content_list[7]) 00040 delta_rss=float(line_content_list[8]) 00041 00042 data.append((event_number,{'vsize':vsize, 00043 'delta_vsize':delta_vsize, 00044 'rss':rss, 00045 'delta_rss':delta_rss})) 00046 i+=1 00047 00048 # skim the second entry when the event number is the same BUG!!!!!!! 00049 # i take elements in couples! 00050 new_data=[] 00051 if data[0][0]==data[1][0]: 00052 print 'Two modules seem to have some output.\nCollapsing ...' 00053 i=0 00054 while True: 00055 dataline1=data[i] 00056 i+=1 00057 dataline2=data[i] 00058 new_eventnumber=dataline1[0] 00059 new_vsize=dataline2[1]['vsize'] 00060 new_delta_vsize=dataline1[1]['delta_vsize']+dataline2[1]['delta_vsize'] 00061 new_rss=dataline2[1]['rss'] 00062 new_delta_rss=dataline1[1]['delta_rss']+dataline2[1]['delta_rss'] 00063 00064 new_data.append((new_eventnumber,{'vsize':new_vsize, 00065 'delta_vsize':new_delta_vsize, 00066 'rss':new_rss, 00067 'delta_rss':new_delta_rss})) 00068 i+=1 00069 if i==len(data): break 00070 00071 data=new_data 00072 print 'Collapsing: Done!' 00073 00074 npoints=len(data) 00075 00076 print '%s values read and stored ...' %npoints 00077 00078 00079 # The Graphs 00080 __argv=sys.argv # trick for a strange behaviour of the TApp.. 00081 sys.argv=sys.argv[:1] 00082 ROOT.gROOT.SetStyle("Plain") # style paranoia 00083 sys.argv=__argv 00084 00085 #Cannot use this option when the logfile includes 00086 #a large number of events... PyRoot seg-faults. 00087 #Set ROOT in batch mode to avoid canvases popping up! 00088 ROOT.gROOT.SetBatch(1) 00089 00090 # Save in file 00091 rootfilename='%s/graphs.root' %outdir 00092 myfile=ROOT.TFile(rootfilename,'RECREATE') 00093 00094 # dictionary of graphs! 00095 graph_dict={} 00096 for value in values_set: 00097 #graph_dict[value] 00098 graph=ROOT.TGraph(npoints) 00099 graph.SetMarkerStyle(8) 00100 graph.SetMarkerSize(.7) 00101 graph.SetMarkerColor(1) 00102 graph.SetLineWidth(3) 00103 graph.SetLineColor(2) 00104 graph.SetTitle(value) 00105 graph.SetName('%s_graph' %value) 00106 00107 00108 #fill the graphs 00109 point_counter=0 00110 for event_number,vals_dict in data: 00111 graph.SetPoint(point_counter, 00112 event_number, 00113 vals_dict[value]) 00114 point_counter+=1 00115 00116 graph.GetXaxis().SetTitle("Event") 00117 last_event=data[-1][0] 00118 graph.GetXaxis().SetRangeUser(0,last_event+1) 00119 graph.GetYaxis().SetTitleOffset(1.3) 00120 graph.GetYaxis().SetTitle("MB") 00121 00122 00123 00124 #print the graphs as files :) 00125 mycanvas=ROOT.TCanvas('%s_canvas' %value) 00126 mycanvas.cd() 00127 graph.Draw("ALP") 00128 00129 mycanvas.Print("%s/%s_graph.gif"%(outdir,value),"gif") 00130 00131 # write it on file 00132 graph.Write() 00133 mycanvas.Write() 00134 00135 myfile.Close() 00136 00137 os.system('pwd') 00138 00139 # The html page!------------------------------------------------------------------------------ 00140 00141 titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\ 00142 %(os.environ['CMSSW_VERSION'],time.asctime()) 00143 #Introducing this if to catch the cmsRelvalreport.py use case of "reuse" of TimingReport 00144 #profile when doing the SimpleMemReport... otherwise the filename for the html 00145 #would be misleadingly TimingReport... 00146 if len(logfile_name)>16 and 'TimingReport.log' in logfile_name[-16:]: 00147 file_name=logfile_name[:-16]+"_SimpleMemReport" 00148 else: 00149 file_name=logfile_name[:-4]+"_SimpleMemReport" 00150 html_file_name='%s/%s.html' %(outdir,file_name) 00151 html_file=open(html_file_name,'w') 00152 html_file.write('<html>\n<body>\n'+\ 00153 titlestring) 00154 html_file.write('<table>\n'+\ 00155 '<tr><td><img src=vsize_graph.gif></img></td>'+\ 00156 '<td><img src=rss_graph.gif></img></td></tr>'+\ 00157 '<tr><td><img src=delta_vsize_graph.gif></img></td>'+\ 00158 '<td><img src=delta_rss_graph.gif></img></td></tr>' +\ 00159 '</table>\n') 00160 00161 html_file.write('\n</body>\n</html>') 00162 html_file.close() 00163 00164 #################################################################################################
string cmsSimplememchecker_parser::default = '' [static] |
Definition at line 177 of file cmsSimplememchecker_parser.py.
string cmsSimplememchecker_parser::dest = 'profile' [static] |
Definition at line 178 of file cmsSimplememchecker_parser.py.
string cmsSimplememchecker_parser::help = 'The profile to manipulate' [static] |
Definition at line 176 of file cmsSimplememchecker_parser.py.
tuple cmsSimplememchecker_parser::parser = optparse.OptionParser(usage) [static] |
Definition at line 174 of file cmsSimplememchecker_parser.py.
tuple cmsSimplememchecker_parser::startevt = int(options.startevt) [static] |
Definition at line 202 of file cmsSimplememchecker_parser.py.
string cmsSimplememchecker_parser::usage = 'simplememchecker_parser.py <options>' [static] |
Definition at line 173 of file cmsSimplememchecker_parser.py.