Skip to content

Commit a4e73cd

Browse files
authored
Merge pull request #10265 from lplarson/compare-branch
2 parents 6915ed5 + 6944c20 commit a4e73cd

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

benchmark/scripts/Benchmark_Driver

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,39 +289,44 @@ def compare(args):
289289
log_dir = args.log_dir
290290
swift_repo = args.swift_repo
291291
compare_script = args.compare_script
292+
baseline_branch = args.baseline_branch
292293
current_branch = get_current_git_branch(swift_repo)
293294
current_branch_dir = os.path.join(log_dir, current_branch)
294-
master_branch_dir = os.path.join(log_dir, 'master')
295-
296-
if current_branch != 'master' and not os.path.isdir(master_branch_dir):
297-
print('Unable to find benchmark logs for master branch. Set a ' +
298-
'baseline benchmark log by passing --benchmark to ' +
299-
'build-script while on master branch.')
295+
baseline_branch_dir = os.path.join(log_dir, baseline_branch)
296+
297+
if current_branch != baseline_branch and \
298+
not os.path.isdir(baseline_branch_dir):
299+
print(('Unable to find benchmark logs for {baseline_branch} branch. ' +
300+
'Set a baseline benchmark log by passing --benchmark to ' +
301+
'build-script while on {baseline_branch} branch.')
302+
.format(baseline_branch=baseline_branch))
300303
return 1
301304

302305
recent_logs = {}
303-
for branch_dir in [current_branch_dir, master_branch_dir]:
306+
for branch_dir in [current_branch_dir, baseline_branch_dir]:
304307
for opt in ['O', 'Onone']:
305308
recent_logs[os.path.basename(branch_dir) + '_' + opt] = sorted(
306309
glob.glob(os.path.join(
307310
branch_dir, 'Benchmark_' + opt + '-*.log')),
308311
key=os.path.getctime, reverse=True)
309312

310-
if current_branch == 'master':
311-
if len(recent_logs['master_O']) > 1 and \
312-
len(recent_logs['master_Onone']) > 1:
313+
if current_branch == baseline_branch:
314+
if len(recent_logs[baseline_branch + '_O']) > 1 and \
315+
len(recent_logs[baseline_branch + '_Onone']) > 1:
313316
compare_logs(compare_script,
314-
recent_logs['master_O'][0],
315-
recent_logs['master_O'][1],
317+
recent_logs[baseline_branch + '_O'][0],
318+
recent_logs[baseline_branch + '_O'][1],
316319
log_dir, 'O')
317320
compare_logs(compare_script,
318-
recent_logs['master_Onone'][0],
319-
recent_logs['master_Onone'][1],
321+
recent_logs[baseline_branch + '_Onone'][0],
322+
recent_logs[baseline_branch + '_Onone'][1],
320323
log_dir, 'Onone')
321324
else:
322-
print('master/master comparison skipped: no previous master logs')
325+
print(('{baseline_branch}/{baseline_branch} comparison ' +
326+
'skipped: no previous {baseline_branch} logs')
327+
.format(baseline_branch=baseline_branch))
323328
else:
324-
# TODO: Check for outdated master branch log
329+
# TODO: Check for outdated baseline branch log
325330
if len(recent_logs[current_branch + '_O']) == 0 or \
326331
len(recent_logs[current_branch + '_Onone']) == 0:
327332
print('branch sanity failure: missing branch logs')
@@ -340,18 +345,20 @@ def compare(args):
340345
recent_logs[current_branch + '_Onone'][1],
341346
log_dir, 'Onone')
342347

343-
if len(recent_logs['master_O']) == 0 or \
344-
len(recent_logs['master_Onone']) == 0:
345-
print('branch/master failure: no master logs')
348+
if len(recent_logs[baseline_branch + '_O']) == 0 or \
349+
len(recent_logs[baseline_branch + '_Onone']) == 0:
350+
print(('branch/{baseline_branch} failure: no {baseline_branch} ' +
351+
'logs')
352+
.format(baseline_branch=baseline_branch))
346353
return 1
347354
else:
348355
compare_logs(compare_script,
349356
recent_logs[current_branch + '_O'][0],
350-
recent_logs['master_O'][0],
357+
recent_logs[baseline_branch + '_O'][0],
351358
log_dir, 'O')
352359
compare_logs(compare_script,
353360
recent_logs[current_branch + '_Onone'][0],
354-
recent_logs['master_Onone'][0],
361+
recent_logs[baseline_branch + '_Onone'][0],
355362
log_dir, 'Onone')
356363

357364
# TODO: Fail on large regressions
@@ -447,6 +454,10 @@ def main():
447454
compare_parser.add_argument(
448455
'--compare-script', required=True,
449456
help='absolute path to compare script')
457+
compare_parser.add_argument(
458+
'--baseline-branch', default='master',
459+
help='attempt to compare results to baseline results for specified '
460+
'branch (default: master)')
450461
compare_parser.set_defaults(func=compare)
451462

452463
args = parser.parse_args()

0 commit comments

Comments
 (0)