@@ -289,39 +289,44 @@ def compare(args):
289
289
log_dir = args .log_dir
290
290
swift_repo = args .swift_repo
291
291
compare_script = args .compare_script
292
+ baseline_branch = args .baseline_branch
292
293
current_branch = get_current_git_branch (swift_repo )
293
294
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 ))
300
303
return 1
301
304
302
305
recent_logs = {}
303
- for branch_dir in [current_branch_dir , master_branch_dir ]:
306
+ for branch_dir in [current_branch_dir , baseline_branch_dir ]:
304
307
for opt in ['O' , 'Onone' ]:
305
308
recent_logs [os .path .basename (branch_dir ) + '_' + opt ] = sorted (
306
309
glob .glob (os .path .join (
307
310
branch_dir , 'Benchmark_' + opt + '-*.log' )),
308
311
key = os .path .getctime , reverse = True )
309
312
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 :
313
316
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 ],
316
319
log_dir , 'O' )
317
320
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 ],
320
323
log_dir , 'Onone' )
321
324
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 ))
323
328
else :
324
- # TODO: Check for outdated master branch log
329
+ # TODO: Check for outdated baseline branch log
325
330
if len (recent_logs [current_branch + '_O' ]) == 0 or \
326
331
len (recent_logs [current_branch + '_Onone' ]) == 0 :
327
332
print ('branch sanity failure: missing branch logs' )
@@ -340,18 +345,20 @@ def compare(args):
340
345
recent_logs [current_branch + '_Onone' ][1 ],
341
346
log_dir , 'Onone' )
342
347
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 ))
346
353
return 1
347
354
else :
348
355
compare_logs (compare_script ,
349
356
recent_logs [current_branch + '_O' ][0 ],
350
- recent_logs ['master_O ' ][0 ],
357
+ recent_logs [baseline_branch + '_O ' ][0 ],
351
358
log_dir , 'O' )
352
359
compare_logs (compare_script ,
353
360
recent_logs [current_branch + '_Onone' ][0 ],
354
- recent_logs ['master_Onone ' ][0 ],
361
+ recent_logs [baseline_branch + '_Onone ' ][0 ],
355
362
log_dir , 'Onone' )
356
363
357
364
# TODO: Fail on large regressions
@@ -447,6 +454,10 @@ def main():
447
454
compare_parser .add_argument (
448
455
'--compare-script' , required = True ,
449
456
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)' )
450
461
compare_parser .set_defaults (func = compare )
451
462
452
463
args = parser .parse_args ()
0 commit comments