ParserArtEvents.py
Go to the documentation of this file.
1 ###########################
2 # Parsed metric
3 class ArtEvents():
4  def __init__(self):
5  self.time_markers = []
6  self.events = {}
7  self.queries = {}
8  self.parsing = {}
9 
10  def addEvent(self, line):
11  this_time = self.time_markers[-1]
12  #print event_iter, this_time
13  self.events[line] = this_time
14 
15  def addQuery(self, line):
16  this_time = self.time_markers[-1]
17  self.queries[line] = this_time
18 
19  def addParsing(self, line):
20  this_time = self.time_markers[-1]
21  self.parsing[line] = this_time
22 
23  #def getEventTime(self, event_iter):
24  #if event_iter in self.events.keys():
25  #return self.events[event_iter]
26  #else:
27  #return None
28 
29  def __repr__(self):
30  _repr = ""
31  _repr += "dbuse: --- Art Events\n"
32  _repr += "dbuse: n time markers: %i\n" %(len(self.time_markers))
33  _repr += "dbuse: n event: %i\n" %(len(self.events))
34  #_repr += "dbuse: 1st event time: %s s\n"%(repr(self.getEventTime(1)))
35  _repr += "dbuse: n queries: %i\n" %(len(self.queries))
36  _repr += "dbuse: n parsing: %i\n" %(len(self.parsing))
37  return _repr
38 ###########################
39 # Parse line
40 def parseLine(line, usage):
41  tokens = line.strip().split()
42  #print tokens
43  if len(tokens) == 0: return
44 
45  if tokens[0] == "TimeMarker:":
46  assert(len(tokens)==2)
47  usage.time_markers.append(float(tokens[1]))
48 
49  if "Begin processing the " in line: usage.addEvent(line)
50  if "processing event:run:" in line: usage.addEvent(line)
51  if "query" in line: usage.addQuery(line)
52  if "parsing" in line: usage.addParsing(line)
53 ###########################
54 # Parse output file
55 def parseLines(lines, verbose=False):
56  if type(lines) != list: lines = lines.split("\n")
57  if verbose: print "prsAT: read %i lines"%len(lines)
58  usage = ArtEvents()
59 
60  # loop over the lines
61  for line in lines:
62  parseLine(line, usage)
63 
64  #print usage
65  return usage
66 ###########################
67 # Parse output file
68 def parseSTDOUT(file_name, verbose=True):
69  if verbose: print "prsAT: --- Parsed STDOUT from file: %s"%file_name
70 
71  lines = open(file_name, "r").readlines()
72  usage = parseLines(lines,verbose=verbose)
73 
74  #print usage
75  return usage
void split(double tt, double *fr)
def addParsing(self, line)
def parseLine(line, usage)
def parseSTDOUT(file_name, verbose=True)
Parse output file.
procfile open("FD_BRL_v0.txt")
def parseLines(lines, verbose=False)
Parse output file.
assert(nhit_max >=nhit_nbins)