3 from __future__
import print_function
4 import os, re, sys, glob
6 import cmsPerfRegress
as cpr
7 from cmsPerfCommons
import Candles, CandFname, getVerFromLog
12 PROG_NAME = os.path.basename(sys.argv[0])
13 parser = opt.OptionParser(usage=
"""%s [OLD_REL_DIR] [NEW_REL_DIR] 15 To compare 2 cmsPerfSuite.py directories pass the previous release as the first argument and the latest release as the second argument """ % PROG_NAME)
19 devel = opt.OptionGroup(parser,
"Developer Options",
20 "Caution: use these options at your own risk." 21 "It is believed that some of them bite.\n")
28 help=
'Show debug output',
31 parser.add_option_group(devel)
32 (options,args) = parser.parse_args()
33 _debug = options.debug
35 if not len(args) == 2:
36 print(
"ERROR: Not enough arguments")
39 path1 = os.path.abspath(args[0])
40 path2 = os.path.abspath(args[1])
41 if os.path.exists(path1)
and os.path.exists(path2):
44 print(
"Error: one of the paths does not exist")
51 oldRelPath = os.path.dirname(adir)
52 oldRelPathDirs = oldRelPath.split(
"/")
53 for dir
in oldRelPathDirs:
59 print(
"oldlog %s"%oldlog)
60 print(
"curdir %s"%curdir)
63 print(
"OLD REL NAME: %s"%oldRelName)
66 rootf =
"simpmem-regress.root" 68 print(
"TRY candle %s"%candle)
69 print(
"HERE Oldlog:%s"%oldlog)
70 print(
"HERE newLog:%s"%newLog)
71 cpr.cmpSimpMemReport(rootf,curdir,oldlog,newLog,1,
True,candle,prevrev = oldRelName)
72 except cpr.SimpMemParseErr
as detail:
73 print(
"WARNING: Could not parse data from log file %s; not performing regression" % detail.message)
74 except OSError
as detail:
75 print(
"WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail)
76 except IOError
as detail:
77 print(
"IOError:", detail)
79 print(
"Successfully compared %s and %s" % (oldlog,newLog))
83 profSets = [
"Callgrind",
92 for candle
in Candles:
94 for profset
in profSets:
96 adir = os.path.join(newdir,
"%s_%s" % (candle,profset))
97 if os.path.exists(adir):
99 print(
"Found directory %s"%adir)
103 if profset ==
"Callgrind" or profset ==
"PU_Callgrind":
105 elif profset ==
"TimeSize" or profset ==
"PU_TimeSize":
106 Profs = [
"TimingReport",
110 elif profset ==
"IgProf" or profset ==
"PU_IgProf" :
111 Profs = [
"IgProfperf",
117 print(
"Checking %s profile(s)"%prof)
118 if prof ==
"EdmSize" or prof ==
"valgrind":
119 stepLogs = glob.glob(
"%s/%s_*_%s" % (adir,CandFname[candle],prof))
120 elif prof ==
"IgProfMemLive" or prof ==
"IgProfMemTotal":
121 stepLogs = glob.glob(
"%s/%s_*_%s.gz" % (adir,CandFname[candle],
"IgProfMemTotal"))
122 elif prof ==
"IgProfperf":
123 stepLogs = glob.glob(
"%s/%s_*_%s.gz" % (adir,CandFname[candle],prof))
124 elif prof ==
"SimpleMemoryCheck":
128 stepLogs = glob.glob(
"%s/%s_*_%s.log" % (adir,CandFname[candle],
'TimingReport'))
129 elif prof ==
"TimingReport":
130 stepLogs = glob.glob(
"%s/%s_*_%s.log" % (adir,CandFname[candle],prof))
133 print(
"Found the following step logs: %s"%stepLogs)
135 profdir = os.path.basename(adir)
139 if prof ==
"TimingReport" or prof ==
"EdmSize" or prof ==
"valgrind" or prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof ==
"IgProfperf":
142 if prof ==
"IgProfMemLive":
143 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],
"IgProfMemTotal"))
145 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],prof))
149 base = os.path.basename(log)
151 if prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof ==
"IgProfperf":
152 base = base.split(
".gz")[0]
154 searchob = stepreg.search(base)
159 step = searchob.groups()[0]
161 outpath = os.path.join(adir,
"%s_%s_%s_regression" % (CandFname[candle],step,prof))
162 oldlog = os.path.join(olddir,
"%s_%s" % (candle,profset),base)
164 if prof ==
"IgProfMemTotal" or prof ==
"IgProfMemLive" or prof ==
"IgProfperf":
165 oldlog = os.path.join(olddir,
"%s_%s" % (candle,profset),base +
".gz")
166 if not os.path.exists(outpath):
168 if os.path.exists(oldlog):
172 if not prof ==
"TimingReport":
173 print(
"** Comparing", candle, step, prof,
"previous release: %s, latest release %s" % (oldlog,log))
176 if prof ==
"EdmSize":
177 cpr.cmpEdmSizeReport(outpath,oldlog,log)
178 elif prof ==
"TimingReport":
179 logdir =
"%s_%s_%s" % (CandFname[candle],step,prof)
180 outd = os.path.join(adir,logdir)
181 rootf =
"timing-regress.root" 182 oldlog = os.path.join(olddir,profdir,base)
183 if os.path.exists(log)
and os.path.exists(oldlog)
and os.path.exists(outd):
184 print(
"** Comparing", candle, step, prof,
"previous release: %s and latest release: %s" % (oldlog,log))
188 cpr.cmpTimingReport(rootf, outd, oldlog, log, 1, batch =
True, prevrev = oldRelName)
190 print(
"WARNING: While comparing", candle, step, prof,
" at least one of the logfiles/directories: old (%s) or new (%s) was not found!!!" % (oldlog,log))
192 elif prof ==
"valgrind":
193 cpr.cmpCallgrindReport(outpath,oldlog,log)
194 elif prof ==
"IgProfperf":
196 cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
197 elif prof ==
"IgProfMemTotal":
198 IgProfMemOpt=
"-y MEM_TOTAL" 199 cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
200 elif prof ==
"IgProfMemLive":
201 IgProfMemOpt=
"-y MEM_LIVE" 202 cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
203 except cpr.PerfReportErr
as detail:
204 print(
"WARNING: Perfreport return non-zero exit status when comparing %s and %s. Perfreport output follows" % (oldlog,log))
205 print(detail.message)
206 except cpr.TimingParseErr
as detail:
207 print(
"WARNING: Could not parse data from log file %s; not performing regression" % detail.message)
208 except OSError
as detail:
209 print(
"WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail)
210 except IOError
as detail:
211 print(
"IOError:", detail)
213 print(
"Successfully compared %s and %s" % (oldlog,log))
215 print(
"WARNING: Could not find an equivalent logfile for %s in the previous release dir %s " % (log,oldlog))
220 elif prof ==
"SimpleMemoryCheck":
224 stepreg = re.compile(
"%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],
"TimingReport"))
225 base = os.path.basename(log)
227 searchob = stepreg.search(base)
232 step = searchob.groups()[0]
233 print(
"and the step taken is %s"%step)
235 oldlog = os.path.join(olddir,
"%s_%s" % (candle,profset),base)
236 if os.path.exists(oldlog):
239 print(
"** Comparing for SimpleMemoryCheck", candle, step, prof,
"previous release: %s, latest release %s" % (oldlog,log))
246 regress = open(
"%s/REGRESSION.%s.vs.%s" % (newdir,
getVerFromLog(olddir),newRelName),
"w")
247 regress.write(olddir)
255 if __name__ ==
"__main__":
def compareSimMemPair(newLog, candle, profdir, curdir, oldlog, oldRelName="")
def getVerFromLog(previous)
S & print(S &os, JobReport::InputFile const &f)
def getOldRelName(oldRelName, adir)
def regressReports(olddir, newdir, oldRelName="", newRelName="")