diff --git a/handlers/timing/TimingParser.py b/handlers/timing/TimingParser.py index ad425c3c3d616570b730334f6b47f983e509e8bd..8848520f355f6d7187e880603e271c1f3972be20 100644 --- a/handlers/timing/TimingParser.py +++ b/handlers/timing/TimingParser.py @@ -14,7 +14,7 @@ class TimingParser: self.root = None self.overall_timing = 0 self.parse(filename) - + def parse(self, logfilename): """ Parse the log file""" @@ -25,7 +25,7 @@ class TimingParser: lastparent = [None] id = 0 regxp = "(TIMER|TimingAuditor).(TIMER|T...)\s+INFO ([\s\w]+?)\s*\|([\d\s\.]+?)\|([\d\s\.]+?)\|([\d\s\.]+?)\|([\d\s\.]+?)\|.*" - regxp_overall_time = "ChronoStatSvc\s+INFO Time User\s+\: Tot\= (\d+\.*\d*).*" + regxp_overall_time = "ChronoStatSvc\s+INFO Time User\s+\: Tot\=\s+(\d+\.*\d*).*" try: logf = open(logfilename, "r") for l in logf.readlines(): @@ -39,7 +39,7 @@ class TimingParser: except IndexError: # BUG: IN some cases we jump one, to be investigated ! parent = lastparent[level -2] - + name = m.group(3).strip() id = id + 1 #print "Id: ", id, "Name: ", name, "Value: ", float(m.group(4)), "Level: ", level, "Entries: ", m.group(7).strip() @@ -56,7 +56,7 @@ class TimingParser: raise Exception(str(self.__class__)+": No result directory, check the given result directory") except IOError: raise Exception(str(self.__class__)+": Data file not found, this handler excepts a 'run.log' in the results directory' ") - + # Getting the actual root "EVENT LOOP" root = lastparent[0] # Sorting all the nodes by CPU usage and setting the "rank" attribute @@ -79,7 +79,7 @@ class TimingParser: json += c.getJSON(False) ct += 1 json += "]" - return json + return json def findByName(self, name): return self.root.findByName(name) @@ -140,7 +140,7 @@ class Node: def actualTimeUsed(self): """ returns the CPU time actually used in the sequence, excluding time used by the children """ - return self.total - self.getSumChildrenTime() + return self.total - self.getSumChildrenTime() def getAllChildren(self): """ Navigate the tree to rturn all the children""" @@ -155,13 +155,13 @@ class Node: """ Find all children matching a given name """ if foundnodes == None: foundnodes = set() - + if re.match(namepattern, self.name): foundnodes.add(self) for c in self.children: foundnodes |= c.getNodesMatching(namepattern, foundnodes) - + return foundnodes @@ -184,7 +184,7 @@ class Node: if c.getMinChildrenRank() < m: m = c.getMinChildrenRank() return m - + def getSumChildrenTime(self): """ Get the sum of CPU time spent by the children """ @@ -192,12 +192,12 @@ class Node: for c in self.children: tmptotal += c.total return tmptotal - + def perLevel(self): """ Percentage of time spent in this algo/seq over the time used by the parent """ if self.parent != None: - return round((self.total * 100.0)/self.parent.total,2) + return round((self.total * 100.0)/self.parent.total,2) else: return 100.0 @@ -232,7 +232,7 @@ class Node: cjson = ', "children":[%s]' % self._childrenjson() tmpl = '{"code":%d, "name":"%s", "rank":%d, "mrank":%d, "childrenTotal":%.2f, "perTotal":%.2f, "perLevel":%.2f, "avgtime":%.2f, "total":%.2f, "entries":%d ' - vals = [ self.id, self.name, self.rank, self.getMinChildrenRank(), self.getSumChildrenTime(), self.perTotal(), + vals = [ self.id, self.name, self.rank, self.getMinChildrenRank(), self.getSumChildrenTime(), self.perTotal(), self.perLevel(), self.value, self.total, self.entries ] if self.parent != None: tmpl += ', "_parentCode":%d %s}' @@ -286,12 +286,12 @@ if __name__ == "__main__": t = TimingParser(filename) #nodelist.append(eventLoop) - + #dvUserSeq = eventLoop.findByName("DaVinciUserSequence") #nodelist.append(dvUserSeq) #for c in dvUserSeq.children: #nodelist.append(c) - + #stripGlobal = dvUserSeq.findByName("StrippingGlobal") #nodelist.append(stripGlobal) #for c in stripGlobal.children: