CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
profilereader.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """module to read profiling information generated by the SimpleProfiling Service
3 """
4 import os
6  """Holds the profiling information about one function
7  """
8  def __init__(self,attrList):
9  self.address =attrList[0]
10  self.name =os.popen("c++filt "+attrList[-1]).read().strip()
11  self.leafCount = int(attrList[1])
12  self.countOfFunctPlusChildWithRecursion = int(attrList[2])
13  self.countOfFunctPlusChild = int(attrList[3])
14  self.fractionInFunctionOnly = float(attrList[4])
15  self.fractionInPath = float(attrList[5])
16  self.__callerTemp = dict()
17  self.__calleeTemp = dict()
18  def addCaller(self,caller,weight):
19  #print caller.name, weight
20  self.__callerTemp.setdefault(caller.address,[0,caller])[0]+=weight
21  def addCallee(self,callee,weight):
22  self.__calleeTemp.setdefault(callee.address,[0,callee])[0]+=weight
23  def normalize(self):
24  self.callerList = list()
25  self.calleeList = list()
26  for caller in self.__callerTemp.keys():
27  (count,_caller) = self.__callerTemp[caller]
28  self.callerList.append((float(count)/self.countOfFunctPlusChildWithRecursion,_caller))
29  for callee in self.__calleeTemp.keys():
30  (count,_callee) = self.__calleeTemp[callee]
31  self.calleeList.append((float(count)/self.countOfFunctPlusChildWithRecursion,_callee))
32  self.callerList.sort()
33  self.callerList.reverse()
34  self.calleeList.sort()
35  self.calleeList.reverse()
36 
37 class Path(object):
38  def __init__(self,attrList):
39  self.count = int(attrList[0])
40  self.functionIds = [int(x) for x in attrList[1:] if x != '\n']
41 
43  def __init__(self,filesToUseInfo,feedBackStream=None):
44  #try to determine the filePrefix from the value given
45  # since caller may have given us just one of the files
46  # instead of the prefix to the files
47  (dir,base) = os.path.split(filesToUseInfo)
48  uniqueID = base.split('_')[1]
49  filePrefix = os.path.join(dir,"profdata_"+uniqueID+"_")
50  if feedBackStream:
51  feedBackStream.write('reading file: '+filePrefix+'names')
52  nameFile = file(filePrefix+'names','r')
55  feedbackIndex = 0
56  for line in nameFile:
57  if feedBackStream and (0 == feedbackIndex % 100):
58  feedBackStream.write('.')
59  feedbackIndex +=1
60  infoList = line.split('\t')
61  self.idToFunctionInfo.setdefault( int(infoList[0]), FunctionInfo(infoList[1:]))
62  self.functionNameToId.setdefault(self.idToFunctionInfo[int(infoList[0])].name, int(infoList[0]))
63  if feedBackStream:
64  feedBackStream.write('\nreading file: '+filePrefix+'paths')
65  pathFile = file(filePrefix+'paths','r')
66  self.paths = list()
67  feedbackIndex = 0
68  for line in pathFile:
69  if feedBackStream and (0 == feedbackIndex % 100):
70  feedBackStream.write('.')
71  feedbackIndex +=1
72  line.strip()
73  path = Path( line.split(' ')[1:])
74  self.paths.append(path)
75  caller = None
76  for funcId in path.functionIds:
77  func = self.idToFunctionInfo[funcId]
78  if caller:
79  func.addCaller(caller,path.count)
80  caller.addCallee(func,path.count)
81  caller = func
82  feedbackIndex = 0
83  if feedBackStream:
84  feedBackStream.write('\nprocessing data:')
85  for x in self.idToFunctionInfo.items():
86  if feedBackStream and (0 == feedbackIndex % 100):
87  feedBackStream.write('.')
88  feedbackIndex +=1
89  x[1].normalize()
90 
91 if __name__ == '__main__':
92  import sys
93  profile = ProfileData(sys.argv[1])
94  print profile.idToFunctionInfo
95 
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
list object
Definition: dbtoconf.py:77
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run