Skip to content

Commit aaa59a0

Browse files
authored
Merge pull request #5632 from graydon/yet-more-scale-test-improvements
2 parents df65ae2 + ac7d397 commit aaa59a0

File tree

1 file changed

+59
-11
lines changed

1 file changed

+59
-11
lines changed

utils/scale-test

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,34 @@ def run_once_with_primary(args, ast, rng, primary_idx):
5252
inputs = [write_input_file(args, ast, d, i) for i in rng]
5353
primary = inputs[primary_idx]
5454
ofile = os.path.join(d, "out.o")
55+
5556
mode = "-c"
5657
if args.parse:
5758
mode = "-parse"
59+
60+
focus = ["-primary-file", primary]
61+
if args.whole_module_optimization:
62+
focus = ['-whole-module-optimization']
63+
64+
opts = []
65+
if args.optimize:
66+
opts = ['-O']
67+
elif args.optimize_none:
68+
opts = ['-Onone']
69+
elif args.optimize_unchecked:
70+
opts = ['-Ounchecked']
71+
72+
extra = args.Xfrontend[:]
73+
if args.debuginfo:
74+
extra.append('-g')
75+
5876
command = [args.swiftc_binary,
5977
"-frontend", mode,
60-
"-o", ofile,
61-
"-primary-file", primary] + inputs
78+
"-o", ofile] + opts + focus + extra + inputs
79+
80+
if args.trace:
81+
print "running: " + " ".join(command)
82+
6283
if args.dtrace:
6384
trace = os.path.join(d, "trace.txt")
6485
script = "pid$target:swiftc:*%s*:entry { @[probefunc] = count() }" % args.select
@@ -164,11 +185,10 @@ def report(args, rng, runs):
164185
b = 0 if abs(b) < 1e-9 else b
165186
rows.append((b, k, vals))
166187
rows.sort()
167-
tolerance = 1.2
168188
for (b, k, vals) in rows:
169-
if b >= tolerance:
189+
if b >= args.threshold:
170190
bad = True
171-
if not args.quiet or b >= tolerance:
191+
if not args.quiet or b >= args.threshold:
172192
print "O(n^%1.1f) : %s" % (b, k)
173193
if args.values:
174194
print " = ", vals
@@ -185,21 +205,30 @@ def main():
185205
parser.add_argument(
186206
'--values', action='store_true',
187207
default=False, help='print stat values')
208+
parser.add_argument(
209+
'--trace', action='store_true',
210+
default=False, help='trace compiler invocations')
188211
parser.add_argument(
189212
'--quiet', action='store_true',
190213
default=False, help='only print superlinear stats')
191214
parser.add_argument(
192-
'--parse', action='store_true',
215+
'--threshold', type=float,
216+
default=1.2, help='exponent beyond which to consider "bad scaling"')
217+
parser.add_argument(
218+
'-parse', '--parse', action='store_true',
193219
default=False, help='only run compiler with -parse')
220+
parser.add_argument(
221+
'-g', '--debuginfo', action='store_true',
222+
default=False, help='run compiler with -g')
223+
parser.add_argument(
224+
'-wmo', '--whole-module-optimization', action='store_true',
225+
default=False, help='run compiler with -whole-module-optimization')
194226
parser.add_argument(
195227
'--dtrace', action='store_true',
196228
default=False, help='use dtrace to sample all functions')
197229
parser.add_argument(
198-
'--multi-file', action='store_true',
199-
default=False, help='vary number of input files as well')
200-
parser.add_argument(
201-
'--sum-multi', action='store_true',
202-
default=False, help='simulate a multi-primary run and sum stats')
230+
'-Xfrontend', action='append',
231+
default=[], help='pass additional args to frontend jobs')
203232
parser.add_argument(
204233
'--begin', type=int,
205234
default=10, help='first value for N')
@@ -219,6 +248,25 @@ def main():
219248
'--debug', action='store_true',
220249
default=False, help='invoke lldb on each scale test')
221250

251+
group = parser.add_mutually_exclusive_group()
252+
group.add_argument(
253+
'-O', '--optimize', action='store_true',
254+
default=False, help='run compiler with -O')
255+
group.add_argument(
256+
'-Onone', '--optimize-none', action='store_true',
257+
default=False, help='run compiler with -Onone')
258+
group.add_argument(
259+
'-Ounchecked', '--optimize-unchecked', action='store_true',
260+
default=False, help='run compiler with -Ounchecked')
261+
262+
group = parser.add_mutually_exclusive_group()
263+
group.add_argument(
264+
'--multi-file', action='store_true',
265+
default=False, help='vary number of input files as well')
266+
group.add_argument(
267+
'--sum-multi', action='store_true',
268+
default=False, help='simulate a multi-primary run and sum stats')
269+
222270
args = parser.parse_args(sys.argv[1:])
223271
(rng, runs) = run_many(args)
224272
if report(args, rng, runs):

0 commit comments

Comments
 (0)