Classes | Functions
ParserDBUsage Namespace Reference

Classes

class  DBUsage
 Parsed metric. More...
 

Functions

def parseLine (line, usage)
 
def parseSTDOUT (file_name, verbose=True)
 Parse output file. More...
 

Function Documentation

def ParserDBUsage.parseLine (   line,
  usage 
)

Definition at line 65 of file ParserDBUsage.py.

References check_time_usage.float, and makeTrainCVSamples.int.

Referenced by parseSTDOUT().

65 def parseLine(line, usage):
66  if " of VirtualMemory" in line:
67  tokens = line.split()
68  assert (tokens[5] == "MB"), "Expecting tokens[5] to be MB, tokens:%s"%repr(tokens)
69  vmem = float(tokens[4])
70  usage.vmem_usage.append(vmem)
71  if " of PhysicalMemory" in line:
72  tokens = line.split()
73  assert (tokens[5] == "MB"), "Expecting tokens[5] to be MB, tokens:%s"%repr(tokens)
74  mem = float(tokens[4])
75  usage.mem_usage.append(mem)
76  if " query took " in line:
77  usage.n_queries+=1
78  tokens = line.split()
79  for i_t, t in enumerate(tokens):
80  if t == "query":
81  assert (tokens[i_t+1] == "took")
82  assert (tokens[i_t+3] == "ms")
83  start_token = i_t
84  time = float(tokens[i_t+2])
85  usage.queries.append(line.strip())
86  usage.query_time.append(time)
87  break
88  if " parsing took " in line:
89  usage.n_queries+=1
90  tokens = line.split()
91  for i_t, t in enumerate(tokens):
92  if t == "parsing":
93  assert (tokens[i_t+1] == "took")
94  assert (tokens[i_t+3] == "ms")
95  start_token = i_t
96  time = float(tokens[i_t+2])
97  usage.parsing_time.append(time)
98  break
99  if "rows from database" in line:
100  tokens = line.split()
101  if (len(tokens) == 5):
102  rows = int(tokens[1])
103  usage.rows.append(rows)
104  else:
105  print "dbuse: ERROR: Expecting line to be 5 words long: %s"%line
106  usage.rows.append(0)
def parseLine(line, usage)
def ParserDBUsage.parseSTDOUT (   file_name,
  verbose = True 
)

Parse output file.

Definition at line 109 of file ParserDBUsage.py.

References open(), and parseLine().

109 def parseSTDOUT(file_name, verbose=True):
110  if verbose: print "prsDB: --- Parsed STDOUT from file: %s"%file_name
111 
112  lines = open(file_name, "r").readlines()
113  if verbose: print "prsDB: read %i lines"%len(lines)
114  usage = DBUsage()
115 
116  # loop over the lines
117  for line in lines:
118  parseLine(line, usage)
119 
120  #print usage
121  return usage
122 
def parseSTDOUT(file_name, verbose=True)
Parse output file.
def parseLine(line, usage)
procfile open("FD_BRL_v0.txt")
Parsed metric.
Definition: ParserDBUsage.py:3