ATLAS Offline Software
MooRTT_summarizeCPU.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 import os
5 import sys
6 import glob
7 print "Summarize CPU"
8 sIn = "*_log"
9 sOut = "cpuSummary.log"
10 sInArray = glob.glob(sIn)
11 fIn = open(sInArray[0])
12 fOut = open(sOut,"w")
13 print fIn
14 # pickle.dump(fIn,fOut)
15 fOut.write(str(fIn)+'\n')
16 lines = fIn.readlines()
17 fIn.close()
18 
19 
20 def getSeconds(line):
21  myString = ''
22  myString = line.split('=')
23 # myString
24 # myString.split('=')
25  myString2 = myString[2].split('(')
26 # val = float(myString[6])
27  val = float(myString2[0])
28  if myString[2].find('[s]') >= 0:
29  val *= 1
30  elif myString[2].find('[min]') >= 0:
31  val *= 60
32  elif myString[2].find('[ms]') >= 0:
33  val *= 0.001
34  elif myString[2].find('[us]') >= 0:
35  val *= 1e-6
36  else : print "ERROR: time units not found"
37  return val
38 
39 
40 mutagimo = 0
41 mugirl = 0
42 innerdet = 0
43 moore = 0
44 muid = 0
45 staco = 0
46 muonboy = 0
47 mutag = 0
48 athena = 0
49 
50 
51 for i in range(len(lines)):
52  if lines[i].find('iPatRec:execute') >= 0 or lines[i].find('InDetPriVxFinder:execute') >= 0 or lines[i].find('InDetTRT_SeededAmbiguitySolver:execute') >= 0 or lines[i].find('InDetAmbiguitySolver:execute') >= 0 or lines[i].find('InDetExtensionProcessor:execute') >= 0 or lines[i].find('InDetSiSpTrackFinder:execute') >= 0 or lines[i].find('InDetTRT_TrackSegmentsFinder:execute') >= 0 or lines[i].find('InDetTRT_StandaloneTrackFinder:execute') >= 0 or lines[i].find('InDetTRT_SeededTrackFinder:execute') >= 0:
53 # Trk_VKalVrtFitter?
54  val = getSeconds(lines[i])
55  innerdet += val
56  print lines[i].strip()
57  fOut.write(str(lines[i].strip())+'\n')
58  elif lines[i].find('MuTagMasterIMO:execute') >= 0:
59  val = getSeconds(lines[i])
60  mutagimo += val
61  print lines[i].strip()
62  fOut.write(str(lines[i].strip())+'\n')
63  elif lines[i].find('MuGirl:execute') >= 0:
64  val = getSeconds(lines[i])
65  mugirl += val
66  print lines[i].strip()
67  fOut.write(str(lines[i].strip())+'\n')
68  elif lines[i].find('MuonCombiTrackBuilder:execute') >= 0 or lines[i].find('MooSegmentMaker:execute') >= 0:
69  val = getSeconds(lines[i])
70  moore += val
71  print lines[i].strip()
72  fOut.write(str(lines[i].strip())+'\n')
73  elif lines[i].find('MuidVertexAssociator:execute') >= 0 or lines[i].find('MuidCombined:execute') >= 0 or lines[i].find('MuidStandalone:execute') >= 0:
74  val = getSeconds(lines[i])
75  muid += val
76  print lines[i].strip()
77  fOut.write(str(lines[i].strip())+'\n')
78  elif lines[i].find('StacoMaster:execute') >= 0 or lines[i].find('StacoDressingTP2Ana:execute') >= 0:
79  val = getSeconds(lines[i])
80  staco += val
81  print lines[i].strip()
82  fOut.write(str(lines[i].strip())+'\n')
83  elif lines[i].find('MboyRec:execute') >= 0:
84  val = getSeconds(lines[i])
85  muonboy += val
86  print lines[i].strip()
87  fOut.write(str(lines[i].strip())+'\n')
88  elif lines[i].find('MuTagMaster:execute') >= 0:
89  val = getSeconds(lines[i])
90  mutag += val
91  print lines[i].strip()
92  fOut.write(str(lines[i].strip())+'\n')
93  elif lines[i].find('AthMasterSeq:execute') >= 0:
94  val = getSeconds(lines[i])
95  athena += val
96  print lines[i].strip()
97  fOut.write(str(lines[i].strip())+'\n')
98 
99 
100 print '*** Summary of average time per event ***'
101 print 'Muid '+str(muid)+' s'
102 print 'Moore '+str(moore)+' s'
103 print 'MuGirl '+str(mugirl)+' s'
104 print 'MuTagIMO '+str(mutagimo)+' s'
105 print '-------------------------'
106 print 'Staco '+str(staco)+' s'
107 print 'Muonboy '+str(muonboy)+' s'
108 print 'MuTag '+str(mutag)+' s'
109 print '-------------------------'
110 print 'InnerDet '+str(innerdet)+' s'
111 print 'Athena '+str(athena)+' s'
112 print 'Muon reconstruction uses '+str(round(100*(muid+moore+mugirl+mutagimo+staco+muonboy+mutag)/athena,2))+'% of total Athena time'
113 fOut.write('*** Summary of average time per event ***\n'
114  +'Muid '+str(muid)+' s\n'
115  +'Moore '+str(moore)+' s\n'
116  +'MuGirl '+str(mugirl)+' s\n'
117  +'MuTagIMO '+str(mutagimo)+' s\n'
118  +'-------------------------\n'
119  +'Staco '+str(staco)+' s\n'
120  +'Muonboy '+str(muonboy)+' s\n'
121  +'MuTag '+str(mutag)+' s\n'
122  +'-------------------------\n'
123  +'InnerDet '+str(innerdet)+' s\n'
124  +'Athena '+str(athena)+' s\n'
125  +'Muon reconstruction uses '+str(round(100*(muid+moore+mugirl+mutagimo+staco+muonboy+mutag)/athena,2))+'% of total Athena time\n' )
126 fOut.close()
127 # MuTagMasterIMO:execute INFO Time User : Tot= 173 [s] Ave/Min/Max=0.863(+-0.376)/0.192/ 3.07 [s] #=200
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
MooRTT_summarizeCPU.getSeconds
def getSeconds(line)
convert lines to seconds ###
Definition: MooRTT_summarizeCPU.py:20
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38