![]() |
![]() |
Functions | |
def | get_max |
def | get_min |
def | manipulate_log |
Variables | |
string | default = '' |
string | dest = 'profile' |
string | help = 'The profile to manipulate' |
tuple | parser = optparse.OptionParser(usage) |
tuple | startevt = float(options.startevt) |
string | usage = 'timing_parser.py <options>' |
def cmsTiming_parser::get_max | ( | data, | ||
index = 1 | ||||
) |
Definition at line 4 of file cmsTiming_parser.py.
00004 : 00005 max_time=-1 00006 for el in data: 00007 sec=el[index] 00008 if max_time<sec: 00009 max_time=sec 00010 return max_time 00011 def get_min(data,index=1):
def cmsTiming_parser::get_min | ( | data, | ||
index = 1 | ||||
) |
Definition at line 12 of file cmsTiming_parser.py.
00012 : 00013 min_time=1e20 00014 for el in data: 00015 sec=el[index] 00016 if min_time>sec: 00017 min_time=sec 00018 return min_time 00019 def manipulate_log(outdir,logfile_name,secsperbin):
def cmsTiming_parser::manipulate_log | ( | outdir, | ||
logfile_name, | ||||
secsperbin | ||||
) |
Definition at line 20 of file cmsTiming_parser.py.
00020 : 00021 00022 import time 00023 import sys 00024 import ROOT 00025 00026 # the fundamental structure: the key is the evt number the value is a list containing 00027 # VSIZE deltaVSIZE RSS deltaRSS 00028 data=[] 00029 00030 # open file and read it and fill the structure! 00031 logfile=open(logfile_name,'r') 00032 logfile_lines=logfile.readlines() 00033 logfile.close() 00034 00035 # we get the info we need! 00036 i=0 00037 while i < len(logfile_lines): 00038 line=logfile_lines[i] 00039 if 'TimeEvent>' in line: 00040 line=line[:-1] #no \n! 00041 line_content_list=line.split(' ') 00042 event_number=int(line_content_list[1]) 00043 seconds=float(line_content_list[3]) 00044 data.append((event_number,seconds)) 00045 i+=1 00046 00047 # init Graph and histo 00048 00049 # The Graphs 00050 __argv=sys.argv # trick for a strange behaviour of the TApp.. 00051 sys.argv=sys.argv[:1] 00052 ROOT.gROOT.SetStyle("Plain") # style paranoia 00053 sys.argv=__argv 00054 #Cannot use this option when the logfile includes 00055 #a large number of events... PyRoot seg-faults. 00056 #Set ROOT in batch mode to avoid canvases popping up! 00057 ROOT.gROOT.SetBatch(1) 00058 00059 # Save in file 00060 rootfilename='%s/graphs.root' %outdir 00061 myfile=ROOT.TFile(rootfilename,'RECREATE') 00062 00063 00064 # Set fancy limits 00065 min_val=get_min(data,1) 00066 max_val=get_max(data,1) 00067 interval=int(max_val-min_val) 00068 00069 min_val=min_val-interval*0.2 00070 max_val=max_val+interval*0.2 00071 interval=int(max_val-min_val) 00072 00073 nbins=int(interval/secsperbin) 00074 00075 print 'Minval=',min_val,' maxval=',max_val, ' interval=',interval 00076 00077 histo=ROOT.TH1F('Seconds per event','Seconds per event',nbins,min_val,max_val) 00078 histo.GetXaxis().SetTitle("s") 00079 00080 npoints=len(data) 00081 00082 graph=ROOT.TGraph(npoints) 00083 graph.SetMarkerStyle(8) 00084 graph.SetMarkerSize(.7) 00085 graph.SetMarkerColor(1) 00086 graph.SetLineWidth(3) 00087 graph.SetLineColor(2) 00088 graph.SetTitle('Seconds per event') 00089 graph.SetName('SecondsPerEvent') 00090 graph.GetXaxis().SetTitle("Event") 00091 00092 last_event=data[-1][0] 00093 print 'last event =',last_event 00094 graph.GetXaxis().SetLimits(0,last_event) 00095 00096 graph.GetYaxis().SetTitleOffset(1.3) 00097 graph.GetYaxis().SetTitle("s") 00098 graph.GetYaxis().SetRangeUser(0,max_val) 00099 00100 00101 00102 # Fill them 00103 00104 evt_counter=0 00105 total=0 00106 for evt_num,secs in data: 00107 graph.SetPoint(evt_counter,evt_num,secs) 00108 histo.Fill(secs) 00109 total+=secs 00110 evt_counter+=1 00111 00112 print 'Total Time=', total 00113 00114 #A line which represents the average is drawn in the TGraph 00115 avg=histo.GetMean() 00116 avg_line=ROOT.TLine(1,avg,last_event,avg) 00117 avg_line.SetLineColor(4) 00118 avg_line.SetLineWidth(2) 00119 00120 # draw and save! 00121 graph_canvas=ROOT.TCanvas('graph_canvas') 00122 graph_canvas.cd() 00123 graph.Draw("ALP") 00124 avg_line.Draw("Same") 00125 00126 graph_canvas.Print("%s/graph.gif" %outdir,"gif") 00127 00128 # write it on file 00129 graph.Write() 00130 graph_canvas.Write() 00131 00132 histo_canvas=ROOT.TCanvas('histo_canvas') 00133 histo_canvas.cd() 00134 histo.Draw('') 00135 00136 histo_canvas.Print("%s/histo.gif" %outdir,"gif") 00137 00138 # write it on file 00139 histo.Write() 00140 histo_canvas.Write() 00141 00142 myfile.Close() 00143 00144 # The html page!------------------------------------------------------------------------------ 00145 00146 titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\ 00147 %(os.environ['CMSSW_VERSION'],time.asctime()) 00148 00149 html_file_name='%s/%s.html' %(outdir,logfile_name[:-4])# a way to say the string until its last but 4th char 00150 html_file=open(html_file_name,'w') 00151 html_file.write('<html>\n<body>\n'+\ 00152 titlestring) 00153 html_file.write('<table>\n'+\ 00154 '<tr><td><img src=graph.gif></img></td></tr>'+\ 00155 '<tr><td><img src=histo.gif></img></td></tr>'+\ 00156 '</table>\n') 00157 html_file.write('\n</body>\n</html>') 00158 html_file.close() 00159 00160 #################################################################################################
string cmsTiming_parser::default = '' [static] |
Definition at line 173 of file cmsTiming_parser.py.
string cmsTiming_parser::dest = 'profile' [static] |
Definition at line 174 of file cmsTiming_parser.py.
Referenced by Clusterizer1DCommons::add(), edm::service::ELadministrator::attach(), dothrow(), edm::service::ELadministrator::finishMsg(), G__TCellDict_83_0_21(), getAnyIMG(), getIMG(), getIMG2(), getIMGTProfile(), qtConnectionCallback(), stor::StorageManager::receiveDataMessage(), stor::StorageManager::receiveDQMMessage(), stor::StorageManager::receiveErrorDataMessage(), stor::StorageManager::receiveRegistryMessage(), CosmicMuonUtilities::stepPropagate(), and SimpleNavigableLayer::wellInside().
string cmsTiming_parser::help = 'The profile to manipulate' [static] |
Definition at line 172 of file cmsTiming_parser.py.
tuple cmsTiming_parser::parser = optparse.OptionParser(usage) [static] |
Definition at line 170 of file cmsTiming_parser.py.
tuple cmsTiming_parser::startevt = float(options.startevt) [static] |
Definition at line 198 of file cmsTiming_parser.py.
string cmsTiming_parser::usage = 'timing_parser.py <options>' [static] |
Definition at line 169 of file cmsTiming_parser.py.