Skip to content

Commit 2a252fb

Browse files
committed
[benchmark] run_smoke_bench cleanup
Removed unused `num_samples` argument and redundant `run_count` variable. Also gather metadata (currently unused). Print the actual threshold in the “How to read the data“ decription.
1 parent a8751cc commit 2a252fb

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

benchmark/scripts/run_smoke_bench

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ def main():
8888
help='In addition to stdout, write the results into a markdown file')
8989
argparser.add_argument(
9090
'-threshold', type=float,
91-
help='The performance threshold in %% which triggers a re-run',
92-
default=5)
93-
argparser.add_argument(
94-
'-num-samples', type=int,
95-
help='The (minimum) number of samples to run', default=3)
91+
help='The performance threshold in %% which triggers a re-run'
92+
' (default: 5)',
93+
default=5.0)
9694
argparser.add_argument(
9795
'-num-reruns', type=int,
9896
help="The number of re-runs until it's assumed to be a real change",
@@ -123,8 +121,9 @@ def test_opt_levels(args):
123121
if not args.skip_performance:
124122
if test_performance(opt_level, args.oldbuilddir[0],
125123
args.newbuilddir[0],
126-
float(args.threshold) / 100, args.num_samples,
127-
args.num_reruns, output_file):
124+
args.threshold / 100,
125+
args.num_reruns,
126+
output_file):
128127
changes = True
129128

130129
# There is no point in reporting code size for Onone.
@@ -145,7 +144,7 @@ def test_opt_levels(args):
145144

146145
if output_file:
147146
if changes:
148-
output_file.write(get_info_text())
147+
output_file.write(get_info_text(args.threshold))
149148
else:
150149
output_file.write("### No performance and code size changes")
151150
output_file.close()
@@ -154,13 +153,14 @@ def test_opt_levels(args):
154153

155154
def measure(driver, tests, i):
156155
"""Log and measure samples of the tests with the given driver."""
157-
msg = ' Iteration {0} for {1}:, '.format(i, driver.args.tests)
156+
msg = ' Iteration {0} for {1}: '.format(i, driver.args.tests)
158157
msg += ('running all tests' if driver.all_tests == tests else
159158
're-testing {0} tests'.format(len(tests)))
160159
log(msg)
161160
driver.tests = tests
162161
return driver.run(
163-
num_iters=1, min_samples=10, sample_time=0.05, quantile=20)
162+
num_iters=1, min_samples=10, sample_time=0.05, quantile=20,
163+
gather_metadata=True)
164164

165165

166166
def merge(results, other_results):
@@ -170,21 +170,20 @@ def merge(results, other_results):
170170
return results
171171

172172

173-
def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
173+
def test_performance(opt_level, old_dir, new_dir, threshold,
174174
num_reruns, output_file):
175175
"""Detect performance changes in benchmarks.
176176
177177
Gather more independent measurements of the change candidates.
178178
"""
179-
180-
i, run_count = 0, 0
179+
i = 0
181180
old, new = [BenchmarkDriver(DriverArgs(dir, optimization=opt_level))
182181
for dir in [old_dir, new_dir]]
183182
results = [measure(driver, driver.tests, i) for driver in [old, new]]
184183
tests = TestComparator(results[0], results[1], threshold)
185184
changed = tests.decreased + tests.increased + tests.added
186185

187-
while len(changed) > 0 and run_count < num_reruns:
186+
while len(changed) > 0 and i < num_reruns:
188187
i += 1
189188
if VERBOSE:
190189
log(' test again: ' + str([test.name for test in changed]))
@@ -193,11 +192,10 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
193192
for the_results, driver in zip(results, [old, new])]
194193
tests = TestComparator(results[0], results[1], threshold)
195194
changed = tests.decreased + tests.increased + tests.added
196-
run_count += 1
197195

198196
log('')
199197
return report_results("Performance: -" + opt_level, None, None,
200-
threshold * 1.4, output_file, *results)
198+
threshold, output_file, *results)
201199

202200

203201
def report_code_size(opt_level, old_dir, new_dir, platform, output_file):
@@ -259,11 +257,11 @@ def report_results(title, old_lines, new_lines, threshold, output_file,
259257
return False
260258

261259

262-
def get_info_text():
260+
def get_info_text(threshold):
263261
text = """
264262
<details>
265263
<summary><strong>How to read the data</strong></summary>
266-
The tables contain differences in performance which are larger than 8% and
264+
The tables contain differences in performance which are larger than {0}% and
267265
differences in code size which are larger than 1%.
268266
269267
If you see any unexpected regressions, you should consider fixing the
@@ -279,7 +277,7 @@ performance team (@eeckstein).
279277
<details>
280278
<summary><strong>Hardware Overview</strong></summary>
281279
282-
"""
280+
""".format(threshold)
283281
po = subprocess.check_output(['system_profiler', 'SPHardwareDataType'])
284282
for line in po.splitlines():
285283
selection = ['Model Name',

0 commit comments

Comments
 (0)