| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

ana.py
Go to the documentation of this file.
1 import sys
2 class FirstSummary:
3 def __init__(self):
4 self.type = ''
5 self.protocol = ''
6 self.nevt = 0
7 self.data={}
8 self.opt={}
9 self.step={}
10 self.stepno={}
11
12 class Summary:
13 def __init__(self):
14 self.type = ''
15 self.protocol = ''
16 self.step = {}
17
18 class Step:
19 def __init__(self):
20 self.name=''
21 self.type=''
22 self.protocol = ''
23 self.data=''
24 self.usage=None
25 self.cpu = 0.
26 self.events = 0
27 self.user=0.
28 self.system=0.
29 self.ellapsed = 0.
30
31 def toString(self):
32 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)
33 s2 = '%8.2e %8.2e %8.2e'%(self.ellapsed/self.events,self.user/self.events,self.system/self.events)
34 return s1+s2
35
36 def diff(self,other):
37 e1 = self.ellapsed/self.events
38 e2 = other.ellapsed/other.events
39 e3 = (self.user+self.system)/self.events
40 e4 = (other.user+other.system)/other.events
41 s1 = '%8.2e %8.2e'%(e1-e2,e3-e4)
42 return s1
43
44 class Summary:
45 def __init__(self):
46 self.step={}
47
48 lines=open(sys.argv[1],"r").readlines()
49 step = None
50 line = 999
51
52 all_summs={}
53 prot=None
54 summary=None
55 for l in lines:
56 if l.find('Write ')==0:
57 itm=l.split(' ')
58 step = 0;
59 line = 0
60 summary = FirstSummary()
61 summary.nevt = int(itm[4])
62 summary.type = itm[1]
63 summary.protocol = itm[3]
64 summary.step[step] = 'Write'
65 all_summs[summary.protocol]=summary
66 summary.stepno[summary.step[step]] = step
67 elif l.find('Read ')==0:
68 itm=l.split(' ')
69 if not all_summs.has_key(itm[3]):
70 summary = FirstSummary()
71 summary.nevt = int(itm[4])
72 summary.type = itm[1]
73 summary.protocol = itm[3]
74 all_summs[summary.protocol]=summary
75 step = 2;
76 line = 0
77 summary.step[step] = 'Read'
78 summary.stepno[summary.step[step]] = step
79 elif l.find('CollWrite')==0:
80 step = 1;
81 line = 0
82 summary.step[step] = 'CollWrite'
83 summary.stepno[summary.step[step]] = step
84 elif l.find('CollRead 90')==0:
85 step = 3;
86 line = 0
87 summary.step[step] = 'CollRead 90'
88 summary.stepno[summary.step[step]] = step
89 elif l.find('CollRead 50')==0:
90 step = 4;
91 line = 0
92 summary.step[step] = 'CollRead 50'
93 summary.stepno[summary.step[step]] = step
94 elif l.find('CollRead 10')==0:
95 step = 5;
96 line = 0
97 summary.step[step] = 'CollRead 10'
98 summary.stepno[summary.step[step]] = step
99
100 if step is not None:
101 line = line+1
102 if line==2:
103 summary.data[step] = l[:-1]
104 elif line==3:
105 summary.opt[step] = summary.nevt
106 if step>1:
107 summary.opt[step] = int(l[l.find(' #=')+3:-1])
108
109
110 steps = {}
111 opts = {}
112 for k in all_summs.keys():
113 summary = all_summs[k]
114 ###print 'Summary: %32s [%s] %d %d steps'%(summary.protocol,summary.type,summary.nevt,len(summary.data),)
115 for s in summary.data.keys():
116 opt=''
117 if summary.opt.has_key(s): opt=summary.opt[s]
118 ###print '%-16s %s'%(summary.step[s],summary.data[s])#,'\n',opt
119 steps[s]=summary.step[s]
120 opts[s]=summary.opt[s]
121
122 sum = {}
123 sum['castor'] = Summary()
124 sum['file'] = Summary()
125
126
127 for sk in steps.keys():
128 i = steps[sk]
129 for k in all_summs.keys():
130 summary = all_summs[k]
131 #print i,'Summary: %32s [%s] %d %d steps'%(summary.protocol,summary.type,summary.nevt,len(summary.data),)
132 for s in summary.data.keys():
133 if i==summary.step[s]:
134 nevt = opts[s]
135 itms = summary.data[s].split('\t')[0].split(' ')
136 #print itms
137 user = float(itms[0][:-1])
138 system = float(itms[1][:-1])
139 cpu = float(itms[3][:-1])
140 ellapsed = (user+system)/cpu*100.0
141 #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,)
142 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,)
143 s2 = '%8.2e %8.2e %8.2e'%(ellapsed/nevt,user/nevt,system/nevt)
144 ###print s1,s2
145
146 item = Step()
147 item.name = summary.step[s]
148 item.type = summary.type
149 item.protocol = summary.protocol
150 item.data = summary.data[s]
151 item.cpu = cpu
152 item.events = nevt
153 item.user=user
154 item.system=system
155 item.ellapsed = ellapsed
156 item.usage = (nevt,cpu,user,system,ellapsed)
157 sum[summary.protocol].step[summary.stepno[i]] = item
158
159 print 132*'-'
160 file = sum['file']
161 castor = sum['castor']
162 for s in file.step.keys():
163 step_f = file.step[s]
164 step_c = castor.step[s]
165 print step_f.toString()
166 print step_c.toString(),step_c.diff(step_f)
167
ana.FirstSummary.opt
opt
Definition: ana.py:8
ana.Step.usage
usage
Definition: ana.py:24
ana.Summary.protocol
protocol
Definition: ana.py:15
ana.Summary.step
step
Definition: ana.py:16
ana.Summary
Definition: ana.py:12
ana.Step.user
user
Definition: ana.py:27
ana.FirstSummary.protocol
protocol
Definition: ana.py:5
ana.Step.ellapsed
ellapsed
Definition: ana.py:29
ana.Step.diff
def diff(self, other)
Definition: ana.py:36
ana.Step.name
name
Definition: ana.py:20
ana.Step.__init__
def __init__(self)
Definition: ana.py:19
ana.Step.toString
def toString(self)
Definition: ana.py:31
ana.Step
Definition: ana.py:18
ana.Step.cpu
cpu
Definition: ana.py:25
ana.FirstSummary.__init__
def __init__(self)
Definition: ana.py:3
ana.Step.events
events
Definition: ana.py:26
ana.FirstSummary.data
data
Definition: ana.py:7
ana.FirstSummary.stepno
stepno
Definition: ana.py:10
ana.Summary.__init__
def __init__(self)
Definition: ana.py:13
ana.Summary.type
type
Definition: ana.py:14
ana.Step.data
data
Definition: ana.py:23
ana.FirstSummary.type
type
Definition: ana.py:4
ana.Step.system
system
Definition: ana.py:28
ana.Step.protocol
protocol
Definition: ana.py:22
ana.FirstSummary.nevt
nevt
Definition: ana.py:6
ana.Step.type
type
Definition: ana.py:21
ana.FirstSummary
Definition: ana.py:2
ana.FirstSummary.step
step
Definition: ana.py:9