Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012

ana.py

Go to the documentation of this file.
00001 import sys
00002 class FirstSummary:
00003   def __init__(self):
00004     self.type = ''
00005     self.protocol = ''
00006     self.nevt = 0
00007     self.data={}
00008     self.opt={}
00009     self.step={}
00010     self.stepno={}
00011 
00012 class Summary:
00013   def __init__(self):
00014     self.type = ''
00015     self.protocol = ''
00016     self.step = {}
00017 
00018 class Step:
00019     def __init__(self):
00020         self.name=''
00021         self.type=''
00022         self.protocol = ''
00023         self.data=''
00024         self.usage=None
00025         self.cpu = 0.
00026         self.events = 0
00027         self.user=0.
00028         self.system=0.
00029         self.ellapsed = 0.
00030         
00031     def toString(self):
00032         s1 = '%-8s %-8s %-12s %7d %8.2f %8.2f %8.2f %7.2f '%(self.type,self.protocol,self.name,self.events,self.ellapsed,self.user,self.system,self.cpu)
00033         s2 = '%8.2e %8.2e %8.2e'%(self.ellapsed/self.events,self.user/self.events,self.system/self.events)
00034         return s1+s2
00035 
00036     def diff(self,other):
00037         e1 = self.ellapsed/self.events
00038         e2 = other.ellapsed/other.events
00039         e3 = (self.user+self.system)/self.events
00040         e4 = (other.user+other.system)/other.events
00041         s1 = '%8.2e %8.2e'%(e1-e2,e3-e4)
00042         return s1
00043     
00044 class Summary:
00045     def __init__(self):
00046         self.step={}
00047 
00048 lines=open(sys.argv[1],"r").readlines()
00049 step = None
00050 line = 999
00051 
00052 all_summs={}
00053 prot=None
00054 summary=None
00055 for l in lines:
00056   if l.find('Write ')==0:
00057     itm=l.split(' ')
00058     step = 0;
00059     line = 0
00060     summary = FirstSummary()    
00061     summary.nevt = int(itm[4])
00062     summary.type = itm[1]
00063     summary.protocol = itm[3]
00064     summary.step[step] = 'Write'
00065     all_summs[summary.protocol]=summary
00066     summary.stepno[summary.step[step]] = step
00067   elif l.find('Read ')==0:
00068     itm=l.split(' ')
00069     if not all_summs.has_key(itm[3]):
00070       summary = FirstSummary()    
00071       summary.nevt = int(itm[4])
00072       summary.type = itm[1]
00073       summary.protocol = itm[3]
00074       all_summs[summary.protocol]=summary
00075     step = 2;
00076     line = 0
00077     summary.step[step] = 'Read'
00078     summary.stepno[summary.step[step]] = step
00079   elif l.find('CollWrite')==0:
00080     step = 1;
00081     line = 0
00082     summary.step[step] = 'CollWrite'
00083     summary.stepno[summary.step[step]] = step
00084   elif l.find('CollRead 90')==0:
00085     step = 3;
00086     line = 0
00087     summary.step[step] = 'CollRead 90'
00088     summary.stepno[summary.step[step]] = step
00089   elif l.find('CollRead 50')==0:
00090     step = 4;
00091     line = 0
00092     summary.step[step] = 'CollRead 50'
00093     summary.stepno[summary.step[step]] = step
00094   elif l.find('CollRead 10')==0:
00095     step = 5;
00096     line = 0
00097     summary.step[step] = 'CollRead 10'
00098     summary.stepno[summary.step[step]] = step
00099 
00100   if step is not None:
00101     line = line+1
00102     if line==2:
00103       summary.data[step] = l[:-1]
00104     elif line==3:
00105       summary.opt[step] = summary.nevt
00106       if step>1:
00107         summary.opt[step] = int(l[l.find(' #=')+3:-1])
00108   
00109 
00110 steps = {}
00111 opts = {}
00112 for k in all_summs.keys():
00113   summary = all_summs[k]
00114   ###print 'Summary:  %32s [%s] %d  %d steps'%(summary.protocol,summary.type,summary.nevt,len(summary.data),)
00115   for s in summary.data.keys():
00116     opt=''
00117     if summary.opt.has_key(s): opt=summary.opt[s]
00118     ###print '%-16s %s'%(summary.step[s],summary.data[s])#,'\n',opt
00119     steps[s]=summary.step[s]
00120     opts[s]=summary.opt[s]
00121 
00122 sum = {}
00123 sum['castor'] = Summary()
00124 sum['file'] = Summary()
00125 
00126 
00127 for sk in steps.keys():
00128   i = steps[sk]
00129   for k in all_summs.keys():
00130     summary = all_summs[k]
00131     #print i,'Summary:  %32s [%s] %d  %d steps'%(summary.protocol,summary.type,summary.nevt,len(summary.data),)
00132     for s in summary.data.keys():
00133       if i==summary.step[s]:
00134         nevt = opts[s]
00135         itms = summary.data[s].split('\t')[0].split(' ')
00136         #print itms
00137         user = float(itms[0][:-1])
00138         system = float(itms[1][:-1])
00139         cpu = float(itms[3][:-1])
00140         ellapsed = (user+system)/cpu*100.0
00141         #print '%-8s %-8s %-12s %s %6.2f %6.2f %4.2f %4.1f'%(summary.type,summary.protocol,summary.step[s],summary.data[s],ellapsed,user,system,cpu,)
00142         s1 = '%-8s %-8s %-12s %8.2f %8.2f %7.2f %4.1f %7d'%(summary.type,summary.protocol,summary.step[s],ellapsed,user,system,cpu,nevt,)
00143         s2 = '%8.2e %8.2e %8.2e'%(ellapsed/nevt,user/nevt,system/nevt)
00144         ###print s1,s2
00145 
00146         item = Step()
00147         item.name = summary.step[s]
00148         item.type = summary.type
00149         item.protocol = summary.protocol
00150         item.data = summary.data[s]
00151         item.cpu = cpu
00152         item.events = nevt
00153         item.user=user
00154         item.system=system
00155         item.ellapsed = ellapsed
00156         item.usage = (nevt,cpu,user,system,ellapsed)
00157         sum[summary.protocol].step[summary.stepno[i]] = item
00158 
00159 print 132*'-'        
00160 file   = sum['file']
00161 castor = sum['castor']
00162 for s in file.step.keys():
00163   step_f = file.step[s]
00164   step_c = castor.step[s]
00165   print step_f.toString()
00166   print step_c.toString(),step_c.diff(step_f)
00167 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:29 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004