11cb0ef41Sopenharmony_ci#!/usr/bin/env python 21cb0ef41Sopenharmony_ci# Copyright 2014 the V8 project authors. All rights reserved. 31cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 41cb0ef41Sopenharmony_ci# found in the LICENSE file. 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci# for py2/py3 compatibility 71cb0ef41Sopenharmony_cifrom __future__ import print_function 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciimport argparse 101cb0ef41Sopenharmony_ciimport os 111cb0ef41Sopenharmony_ciimport subprocess 121cb0ef41Sopenharmony_ciimport sys 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciBOTS = { 151cb0ef41Sopenharmony_ci '--linux32': 'v8_linux32_perf_try', 161cb0ef41Sopenharmony_ci '--linux64': 'v8_linux64_perf_try', 171cb0ef41Sopenharmony_ci '--nexus5': 'v8_nexus5_perf_try', 181cb0ef41Sopenharmony_ci '--nexus7': 'v8_nexus7_perf_try', 191cb0ef41Sopenharmony_ci '--pixel2': 'v8_pixel2_perf_try', 201cb0ef41Sopenharmony_ci} 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciDEFAULT_BOTS = [ 231cb0ef41Sopenharmony_ci 'v8_linux32_perf_try', 241cb0ef41Sopenharmony_ci 'v8_linux64_perf_try', 251cb0ef41Sopenharmony_ci] 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciPUBLIC_BENCHMARKS = [ 281cb0ef41Sopenharmony_ci 'arewefastyet', 291cb0ef41Sopenharmony_ci 'ares6', 301cb0ef41Sopenharmony_ci 'blazor', 311cb0ef41Sopenharmony_ci 'compile', 321cb0ef41Sopenharmony_ci 'embenchen', 331cb0ef41Sopenharmony_ci 'emscripten', 341cb0ef41Sopenharmony_ci 'jetstream', 351cb0ef41Sopenharmony_ci 'jsbench', 361cb0ef41Sopenharmony_ci 'jstests', 371cb0ef41Sopenharmony_ci 'kraken_orig', 381cb0ef41Sopenharmony_ci 'massive', 391cb0ef41Sopenharmony_ci 'memory', 401cb0ef41Sopenharmony_ci 'octane', 411cb0ef41Sopenharmony_ci 'octane-noopt', 421cb0ef41Sopenharmony_ci 'octane-pr', 431cb0ef41Sopenharmony_ci 'octane-tf', 441cb0ef41Sopenharmony_ci 'octane-tf-pr', 451cb0ef41Sopenharmony_ci 'sunspider', 461cb0ef41Sopenharmony_ci 'unity', 471cb0ef41Sopenharmony_ci 'wasm', 481cb0ef41Sopenharmony_ci 'web-tooling-benchmark', 491cb0ef41Sopenharmony_ci] 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciV8_BASE = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_cidef main(): 541cb0ef41Sopenharmony_ci parser = argparse.ArgumentParser(description='') 551cb0ef41Sopenharmony_ci parser.add_argument('benchmarks', nargs='+', help='The benchmarks to run.') 561cb0ef41Sopenharmony_ci parser.add_argument('--extra-flags', default='', 571cb0ef41Sopenharmony_ci help='Extra flags to be passed to the executable.') 581cb0ef41Sopenharmony_ci parser.add_argument('-r', '--revision', type=str, default=None, 591cb0ef41Sopenharmony_ci help='Revision (use full hash!) to use for the try job; ' 601cb0ef41Sopenharmony_ci 'default: the revision will be determined by the ' 611cb0ef41Sopenharmony_ci 'try server; see its waterfall for more info') 621cb0ef41Sopenharmony_ci parser.add_argument('-v', '--verbose', action='store_true', 631cb0ef41Sopenharmony_ci help='Print debug information') 641cb0ef41Sopenharmony_ci parser.add_argument('-c', '--confidence-level', type=float, 651cb0ef41Sopenharmony_ci help='Repeatedly runs each benchmark until specified ' 661cb0ef41Sopenharmony_ci 'confidence level is reached. The value is interpreted ' 671cb0ef41Sopenharmony_ci 'as the number of standard deviations from the mean that ' 681cb0ef41Sopenharmony_ci 'all values must lie within. Typical values are 1, 2 and ' 691cb0ef41Sopenharmony_ci '3 and correspond to 68%%, 95%% and 99.7%% probability ' 701cb0ef41Sopenharmony_ci 'that the measured value is within 0.1%% of the true ' 711cb0ef41Sopenharmony_ci 'value. Larger values result in more retries and thus ' 721cb0ef41Sopenharmony_ci 'longer runtime, but also provide more reliable results.') 731cb0ef41Sopenharmony_ci for option in sorted(BOTS): 741cb0ef41Sopenharmony_ci parser.add_argument( 751cb0ef41Sopenharmony_ci option, dest='bots', action='append_const', const=BOTS[option], 761cb0ef41Sopenharmony_ci help='Add %s trybot.' % BOTS[option]) 771cb0ef41Sopenharmony_ci options = parser.parse_args() 781cb0ef41Sopenharmony_ci if not options.bots: 791cb0ef41Sopenharmony_ci print('No trybots specified. Using default %s.' % ','.join(DEFAULT_BOTS)) 801cb0ef41Sopenharmony_ci options.bots = DEFAULT_BOTS 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci if not options.benchmarks: 831cb0ef41Sopenharmony_ci print('Please specify the benchmarks to run as arguments.') 841cb0ef41Sopenharmony_ci return 1 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci for benchmark in options.benchmarks: 871cb0ef41Sopenharmony_ci if benchmark not in PUBLIC_BENCHMARKS: 881cb0ef41Sopenharmony_ci print ('%s not found in our benchmark list. The respective trybot might ' 891cb0ef41Sopenharmony_ci 'fail, unless you run something this script isn\'t aware of. ' 901cb0ef41Sopenharmony_ci 'Available public benchmarks: %s' % (benchmark, PUBLIC_BENCHMARKS)) 911cb0ef41Sopenharmony_ci print('Proceed anyways? [Y/n] ', end=' ') 921cb0ef41Sopenharmony_ci answer = sys.stdin.readline().strip() 931cb0ef41Sopenharmony_ci if answer != "" and answer != "Y" and answer != "y": 941cb0ef41Sopenharmony_ci return 1 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci assert '"' not in options.extra_flags and '\'' not in options.extra_flags, ( 971cb0ef41Sopenharmony_ci 'Invalid flag specification.') 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_ci # Ensure depot_tools are updated. 1001cb0ef41Sopenharmony_ci subprocess.check_output( 1011cb0ef41Sopenharmony_ci 'update_depot_tools', shell=True, stderr=subprocess.STDOUT, cwd=V8_BASE) 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci cmd = ['git cl try', '-B', 'luci.v8-internal.try'] 1041cb0ef41Sopenharmony_ci cmd += ['-b %s' % bot for bot in options.bots] 1051cb0ef41Sopenharmony_ci if options.revision: 1061cb0ef41Sopenharmony_ci cmd.append('-r %s' % options.revision) 1071cb0ef41Sopenharmony_ci benchmarks = ['"%s"' % benchmark for benchmark in options.benchmarks] 1081cb0ef41Sopenharmony_ci cmd.append('-p \'testfilter=[%s]\'' % ','.join(benchmarks)) 1091cb0ef41Sopenharmony_ci if options.extra_flags: 1101cb0ef41Sopenharmony_ci cmd.append('-p \'extra_flags="%s"\'' % options.extra_flags) 1111cb0ef41Sopenharmony_ci if options.confidence_level: 1121cb0ef41Sopenharmony_ci cmd.append('-p confidence_level=%f' % options.confidence_level) 1131cb0ef41Sopenharmony_ci if options.verbose: 1141cb0ef41Sopenharmony_ci cmd.append('-vv') 1151cb0ef41Sopenharmony_ci print('Running %s' % ' '.join(cmd)) 1161cb0ef41Sopenharmony_ci subprocess.check_call(' '.join(cmd), shell=True, cwd=V8_BASE) 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ciif __name__ == '__main__': # pragma: no cover 1191cb0ef41Sopenharmony_ci sys.exit(main()) 120