Option parser returns : Command set to run on each (or all) machines, port to connect to server, List of machines to connect to, File to pickle results to, Dictionary to index which command set to use for which machine.
25 def _isValidPerfCmdsDef(alist):
28 isdict = type(item) == type({})
32 out = out
and key
in validPerfSuitKeys
34 out = out
and type(item[key]) == type(
"")
36 out = out
and type(item[key]) == type(
"")
37 elif key ==
"castordir":
38 out = out
and type(item[key]) == type(
"")
39 elif key ==
"perfsuitedir":
40 out = out
and type(item[key]) == type(
"")
41 elif key ==
"TimeSizeEvents":
42 out = out
and type(item[key]) == type(123)
43 elif key ==
"TimeSizeCandles":
44 out = out
and type(item[key]) == type(
"")
45 elif key ==
"CallgrindEvents":
46 out = out
and type(item[key]) == type(123)
47 elif key ==
"CallgrindCandles":
48 out = out
and type(item[key]) == type(
"")
49 elif key ==
"IgProfEvents":
50 out = out
and type(item[key]) == type(123)
51 elif key ==
"IgProfCandles":
52 out = out
and type(item[key]) == type(
"")
53 elif key ==
"MemcheckEvents":
54 out = out
and type(item[key]) == type(123)
55 elif key ==
"MemcheckCandles":
56 out = out
and type(item[key]) == type(
"")
57 elif key ==
"cmsScimark":
58 out = out
and type(item[key]) == type(123)
59 elif key ==
"cmsScimarkLarge":
60 out = out
and type(item[key]) == type(123)
61 elif key ==
"cmsdriverOptions":
62 out = out
and type(item[key]) == type(
"")
63 elif key ==
"stepOptions":
64 out = out
and type(item[key]) == type(
"")
65 elif key ==
"quicktest":
66 out = out
and type(item[key]) == type(
False)
67 elif key ==
"profilers":
68 out = out
and type(item[key]) == type(
"")
69 elif key ==
"prevrel":
70 out = out
and type(item[key]) == type(
"")
71 elif key ==
"isAllCandles":
72 out = out
and type(item[key]) == type(
False)
73 elif key ==
"candles":
74 out = out
and type(item[key]) == type(
"")
75 elif key ==
"bypasshlt":
76 out = out
and type(item[key]) == type(
False)
77 elif key ==
"runonspare":
78 out = out
and type(item[key]) == type(
False)
79 elif key ==
"logfile":
80 out = out
and type(item[key]) == type(
"")
83 parser = opt.OptionParser(usage=(
"""%s [Options]""" % PROG_NAME))
85 parser.add_option(
'-p',
90 help=
'Connect to server on a particular port',
94 parser.add_option(
'-o',
99 help=
'File to output data to',
103 parser.add_option(
'-m',
109 help=
'Machines to run the benchmarking on, for each machine add another one of these options',
110 metavar=
'<MACHINES>',
113 parser.add_option(
'-f',
119 help=
'A files of cmsPerfSuite.py commands to execute on the machines, if more than one of these options is passed and the number of these options is the same as the number of machines, the x-th machine will use the x-th config file.',
123 (options, args) = parser.parse_args()
128 outfile = options.outfile
129 if not outfile ==
"":
130 outfile = os.path.abspath(options.outfile)
131 outdir = os.path.dirname(outfile)
132 if not os.path.isdir(outdir):
133 parser.error(
"ERROR: %s is not a valid directory to create %s" % (outdir,os.path.basename(outfile)))
136 outfile = os.path.join(os.getcwd(),
"cmsmultiperfdata.pypickle")
138 if os.path.exists(outfile):
139 parser.error(
"ERROR: outfile %s already exists" % outfile)
147 cmscmdfiles = options.cmscmdfile
148 if len(cmscmdfiles) <= 0:
149 parser.error(
"A valid python file defining a list of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program")
152 for cmscmdfile
in cmscmdfiles:
153 cmdfile = os.path.abspath(cmscmdfile)
155 if os.path.isfile(cmdfile):
158 cmsperf_cmds.append(listperfsuitekeywords)
159 except (SyntaxError)
as detail:
160 parser.error(
"ERROR: %s must be a valid python file" % cmdfile)
162 except (NameError)
as detail:
163 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program: %s" % (cmdfile,str(detail)))
167 if not type(cmsperf_cmds[-1]) == type([]):
168 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program 2" % cmdfile)
170 if not _isValidPerfCmdsDef(cmsperf_cmds[-1]):
171 parser.error(
"ERROR: %s must contain a list (variable named listperfsuitekeywords) of dictionaries that represents a list of cmsPerfSuite keyword arguments must be passed to this program 3" % cmdfile)
175 parser.error(
"ERROR: %s is not a file" % cmdfile)
182 if options.port == -1:
187 machines = options.machines
192 if len(machines) <= 0:
193 parser.error(
"you must specify at least one machine to benchmark")
195 machines = map(
lambda x: x.strip(),machines)
197 for machine
in machines:
199 output = socket.getaddrinfo(machine,port)
200 except socket.gaierror:
201 parser.error(
"ERROR: Can not resolve machine address %s (must be ip{4,6} or hostname)" % machine)
208 if len(cmsperf_cmds) == 1:
209 for machine
in machines:
212 cmdindex[machine] = 0
214 if not len(cmsperf_cmds) == len(machines):
215 parser.error(
"if more than one configuration file was specified you must specify a configuration file for each machine.")
218 for i
in range(len(machines)):
221 cmdindex[machine] = i
223 return (cmsperf_cmds, port, machines, outfile, cmdindex)