3 import os, re, sys, glob
5 import cmsPerfRegress
as cpr
6 from cmsPerfCommons
import Candles, CandFname, getVerFromLog
11 PROG_NAME = os.path.basename(sys.argv[0])
12 parser = opt.OptionParser(usage=
"""%s [OLD_REL_DIR] [NEW_REL_DIR] 14 To compare 2 cmsPerfSuite.py directories pass the previous release as the first argument and the latest release as the second argument """ % PROG_NAME)
18 devel = opt.OptionGroup(parser,
"Developer Options",
19 "Caution: use these options at your own risk." 20 "It is believed that some of them bite.\n")
27 help=
'Show debug output',
30 parser.add_option_group(devel)
31 (options,args) = parser.parse_args()
32 _debug = options.debug
34 if not len(args) == 2:
35 print "ERROR: Not enough arguments" 38 path1 = os.path.abspath(args[0])
39 path2 = os.path.abspath(args[1])
40 if os.path.exists(path1)
and os.path.exists(path2):
43 print "Error: one of the paths does not exist" 50 oldRelPath = os.path.dirname(adir)
51 oldRelPathDirs = oldRelPath.split(
"/")
52 for dir
in oldRelPathDirs:
58 print "oldlog %s"%oldlog
59 print "curdir %s"%curdir
62 print "OLD REL NAME: %s"%oldRelName
65 rootf =
"simpmem-regress.root" 67 print "TRY candle %s"%candle
68 print "HERE Oldlog:%s"%oldlog
69 print "HERE newLog:%s"%newLog
70 cpr.cmpSimpMemReport(rootf,curdir,oldlog,newLog,1,
True,candle,prevrev = oldRelName)
71 except cpr.SimpMemParseErr
as detail:
72 print "WARNING: Could not parse data from log file %s; not performing regression" % detail.message
73 except OSError
as detail:
74 print "WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail
75 except IOError
as detail:
76 print "IOError:", detail
78 print "Successfully compared %s and %s" % (oldlog,newLog)
82 profSets = [
"Callgrind",
91 for candle
in Candles:
93 for profset
in profSets:
95 adir = os.path.join(newdir,
"%s_%s" % (candle,profset))
96 if os.path.exists(adir):
98 print "Found directory %s"%adir
102 if profset ==
"Callgrind" or profset ==
"PU_Callgrind":
104 elif profset ==
"TimeSize" or profset ==
"PU_TimeSize":
105 Profs = [
"TimingReport",
109 elif profset ==
"IgProf" or profset ==
"PU_IgProf" :
110 Profs = [
"IgProfperf",
116 print "Checking %s profile(s)"%prof
117 if prof ==
"EdmSize" or prof ==
"valgrind":
118 stepLogs = glob.glob(
"%s/%s_*_%s" % (adir,CandFname[candle],prof))
119 elif prof ==
"IgProfMemLive" or prof ==
"IgProfMemTotal":
120 stepLogs = glob.glob(
"%s/%s_*_%s.gz" % (adir,CandFname[candle],
"IgProfMemTotal"))
121 elif prof ==
"IgProfperf":
122 stepLogs = glob.glob(
"%s/%s_*_%s.gz" % (adir,CandFname[candle],prof))
123 elif prof ==
"SimpleMemoryCheck":
127 stepLogs = glob.glob(
"%s/%s_*_%s.log" % (adir,CandFname[candle],
'TimingReport'))
128 elif prof ==
"TimingReport":
129 stepLogs = glob.glob(
"%s/%s_*_%s.log" % (adir,CandFname[candle],prof))
132 print "Found the following step logs: %s"%stepLogs
134 profdir = os.path.basename(adir)
138 if prof ==
"TimingReport" or prof ==
"EdmSize" or prof ==
"valgrind" or prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof ==
"IgProfperf":
141 if prof ==
"IgProfMemLive":
142 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],
"IgProfMemTotal"))
144 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],prof))
148 base = os.path.basename(log)
150 if prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof ==
"IgProfperf":
151 base = base.split(
".gz")[0]
153 searchob = stepreg.search(base)
158 step = searchob.groups()[0]
160 outpath = os.path.join(adir,
"%s_%s_%s_regression" % (CandFname[candle],step,prof))
161 oldlog = os.path.join(olddir,
"%s_%s" % (candle,profset),base)
163 if prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof ==
"IgProfperf":
164 oldlog = os.path.join(olddir,
"%s_%s" % (candle,profset),base +
".gz")
165 if not os.path.exists(outpath):
167 if os.path.exists(oldlog):
171 if not prof ==
"TimingReport":
172 print "** Comparing", candle, step, prof,
"previous release: %s, latest release %s" % (oldlog,log)
175 if prof ==
"EdmSize":
176 cpr.cmpEdmSizeReport(outpath,oldlog,log)
177 elif prof ==
"TimingReport":
178 logdir =
"%s_%s_%s" % (CandFname[candle],step,prof)
179 outd = os.path.join(adir,logdir)
180 rootf =
"timing-regress.root" 181 oldlog = os.path.join(olddir,profdir,base)
182 if os.path.exists(log)
and os.path.exists(oldlog)
and os.path.exists(outd):
183 print "** Comparing", candle, step, prof,
"previous release: %s and latest release: %s" % (oldlog,log)
187 cpr.cmpTimingReport(rootf, outd, oldlog, log, 1, batch =
True, prevrev = oldRelName)
189 print "WARNING: While comparing", candle, step, prof,
" at least one of the logfiles/directories: old (%s) or new (%s) was not found!!!" % (oldlog,log)
191 elif prof ==
"valgrind":
192 cpr.cmpCallgrindReport(outpath,oldlog,log)
193 elif prof ==
"IgProfperf":
195 cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
196 elif prof ==
"IgProfMemTotal":
197 IgProfMemOpt=
"-y MEM_TOTAL" 198 cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
199 elif prof ==
"IgProfMemLive":
200 IgProfMemOpt=
"-y MEM_LIVE" 201 cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
202 except cpr.PerfReportErr
as detail:
203 print "WARNING: Perfreport return non-zero exit status when comparing %s and %s. Perfreport output follows" % (oldlog,log)
205 except cpr.TimingParseErr
as detail:
206 print "WARNING: Could not parse data from log file %s; not performing regression" % detail.message
207 except OSError
as detail:
208 print "WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail
209 except IOError
as detail:
210 print "IOError:", detail
212 print "Successfully compared %s and %s" % (oldlog,log)
214 print "WARNING: Could not find an equivalent logfile for %s in the previous release dir %s " % (log,oldlog)
219 elif prof ==
"SimpleMemoryCheck":
223 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],
"TimingReport"))
224 base = os.path.basename(log)
226 searchob = stepreg.search(base)
231 step = searchob.groups()[0]
232 print "and the step taken is %s"%step
234 oldlog = os.path.join(olddir,
"%s_%s" % (candle,profset),base)
235 if os.path.exists(oldlog):
238 print "** Comparing for SimpleMemoryCheck", candle, step, prof,
"previous release: %s, latest release %s" % (oldlog,log)
245 regress = open(
"%s/REGRESSION.%s.vs.%s" % (newdir,
getVerFromLog(olddir),newRelName),
"w")
246 regress.write(olddir)
254 if __name__ ==
"__main__":
def compareSimMemPair(newLog, candle, profdir, curdir, oldlog, oldRelName="")
def getVerFromLog(previous)
def getOldRelName(oldRelName, adir)
def regressReports(olddir, newdir, oldRelName="", newRelName="")