test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cmsPerfHarvest.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from cmsPerfCommons import Candles, CandFname
3 import optparse as opt
4 import cmsPerfRegress as cpr
5 import sys, os, glob, re
6 
7 _PROG_NAME = os.path.basename(sys.argv[0])
8 
9 ###################
10 # Parse options
11 #
13  parser = opt.OptionParser(usage="""./%s [perf dir] [options]""" % _PROG_NAME)
14 
15  (options, args) = parser.parse_args()
16 
17  if not len(args) == 1:
18  parser.error("You have not supplied a perfsuite directory.")
19  sys.exit()
20 
21  args[0] = os.path.abspath(args[0])
22 
23  ###########
24  # Check existance of the directory supplied
25  #
26  if not os.path.isdir(args[0]):
27  parser.error("You have not provided a valid perfsuite output directory")
28  sys.exit()
29 
30  perfdir = args[0]
31 
32  return (perfdir)
33 
34 #################
35 # Harvest information from a timesize directory, currently only retrieves TimingReport information
36 #
37 def visit_timesize_steps(candle,profsetdir):
38  out = {}
39  # Just do timing report for now
40  globpath = os.path.join(profsetdir,"%s_*_TimingReport.log" % CandFname[candle])
41  globs = glob.glob(globpath)
42  if len(globs) > 0:
43  stepreg = re.compile("%s_([^_]*)_TimingReport.log" % CandFname[candle])
44  for globule in globs:
45  base = os.path.basename(globule)
46  found = stepreg.search(base)
47  if found:
48  step = found.groups()[0]
49  try:
50  if step == None:
51  print "Error: could not resolve step something is wrong"
52  step = "None"
53  if not out.has_key("TimingReport"):
54  out["TimingReport"] = {}
55  stepdict = out["TimingReport"]
56  stepdict[step] = cpr.getTimingLogData(globule)
57  out["TimingReport"] = stepdict
58  except (OSError, IOError), detail:
59  print detail
60  else:
61  print "Error: Could not determine step from %s" % base
62  return out
63 
64 ###############
65 # Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment
66 #
67 def visit(visitdir):
68  out = {}
69  for candle in Candles:
70  globpath = os.path.join(visitdir,"%s_*" % (candle))
71  globs = glob.glob(globpath)
72  if len(globs) > 0:
73  profsetreg = re.compile("%s_(.*)" % candle)
74  for globule in globs:
75  base = os.path.basename(globule)
76  found = profsetreg.search(base)
77  if found:
78  profset = found.groups()[0]
79  if profset == "TimeSize": # Just do timesize for now!
80  if candle == None:
81  print "Error: could not resolve candle something is wrong"
82  candle = "None"
83  if profset == None:
84  print "Error: could not resolve profset something is wrong"
85  profset = "None"
86  if not out.has_key(candle):
87  out[candle] = {}
88  candledict = out[candle]
89  if candledict.has_key(profset):
90  print "Error: we already have a profset that matches %s" % str(profset)
91  else:
92  candledict[profset] = visit_timesize_steps(candle,globule)
93  out[candle] = candledict
94  return out
95 
96 ###############
97 # Harvest all data from a perfsuite directory (if cpu subdirectories exist, it will examine them)
98 #
99 def harvest(perfdir):
100  cpureg = re.compile("cpu_([0-9][0-9]*)")
101  out = {}
102  globpath = os.path.join(perfdir, "cpu_*")
103  globs = glob.glob(globpath)
104  if len(globs) > 0:
105  for globule in globs:
106  base = os.path.basename(globule)
107  found = cpureg.search(base)
108  if found:
109  cpuid = found.groups()[0]
110  if out.has_key(cpuid):
111  print "Error: we already have a cpu run with this id %s ! Skipping..." % cpuid
112  else:
113  if cpuid == None:
114  print "Error: could not resolve cpuid something is wrong"
115  cpuid = "None"
116  out[cpuid] = visit(globule)
117  else:
118  print "Error: could not determine valid cpu id from %s ! Skipping..." % base
119 
120  else:
121  out["None"] = visit(perfdir)
122 
123  return out
124 
125 if __name__ == "__main__":
126  (perfdir) = optionParse()
127  print harvest(perfdir)
def visit_timesize_steps
Harvest information from a timesize directory, currently only retrieves TimingReport information...
def visit
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
def optionParse
Parse options.
def harvest
Harvest all data from a perfsuite directory (if cpu subdirectories exist, it will examine them) ...