diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-15 03:23:48 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-15 03:23:48 +0000 |
commit | 3b46527da85b8139d5fcf887387bcd4de20dec41 (patch) | |
tree | 35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /deprecated/cwp/performance/experiment_gen.py | |
parent | 62564f20dc6f3a88caed664d54fc00dbf3bf7373 (diff) | |
parent | b75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff) | |
download | toolchain-utils-android11-d1-s6-release.tar.gz |
Snap for 6210127 from b75f321fc8978b92ce3db6886ccb966768f0c7a8 to rvc-d1-releaseandroid-11.0.0_r9android-11.0.0_r8android-11.0.0_r7android-11.0.0_r15android-11.0.0_r14android-11.0.0_r13android-11.0.0_r12android-11.0.0_r11android-11.0.0_r10android11-d1-s7-releaseandroid11-d1-s6-releaseandroid11-d1-s5-releaseandroid11-d1-s1-releaseandroid11-d1-release
Change-Id: I508eae962f523cfa857b4da7c77fdb8a70dfab1e
Diffstat (limited to 'deprecated/cwp/performance/experiment_gen.py')
-rw-r--r-- | deprecated/cwp/performance/experiment_gen.py | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/deprecated/cwp/performance/experiment_gen.py b/deprecated/cwp/performance/experiment_gen.py new file mode 100644 index 00000000..a12da2c5 --- /dev/null +++ b/deprecated/cwp/performance/experiment_gen.py @@ -0,0 +1,138 @@ +# Copyright 2012 Google Inc. All Rights Reserved. +"""This script generates a crosperf overhead-testing experiment file for MoreJS. + +Use: experiment_gen.py --crosperf=/home/mrdmnd/depot2/crosperf --chromeos_root= +/home/mrdmnd/chromiumos --remote-host=chromeos-zgb3.mtv --board=x86-zgb --event= +cycles -F 10 -F 20 -c 10582 -c 10785211 --perf_options="-g" +""" + +import optparse +import subprocess +import sys +import time + +HEADER = """ +board: %s +remote: %s +benchmark: baseline { + iterations: %s + autotest_name: desktopui_PyAutoPerfTests + autotest_args: --args='--iterations=%s perf.PageCyclerTest.testMoreJSFile' +}""" + +EXPERIMENT = """ +benchmark: %s { + iterations: %s + autotest_name: desktopui_PyAutoPerfTests + autotest_args: --args='--iterations=%s perf.PageCyclerTest.testMoreJSFile' --profiler=custom_perf --profiler_args='perf_options="record -a %s %s -e %s"' \n}""" # pylint: disable-msg=C6310 + +DEFAULT_IMAGE = """ +default { + chromeos_image: %s/src/build/images/%s/latest/chromiumos_test_image.bin +}""" + + +def main(): + parser = optparse.OptionParser() + parser.add_option('--crosperf', + dest='crosperf_root', + action='store', + default='/home/mrdmnd/depot2/crosperf', + help='Crosperf root directory.') + parser.add_option('--chromeos_root', + dest='chromeos_root', + action='store', + default='/home/mrdmnd/chromiumos', + help='ChromiumOS root directory.') + parser.add_option('--remote', + dest='remote', + action='store', + help='Host to run test on. Required.') + parser.add_option('--board', + dest='board', + action='store', + help='Board architecture to run on. Required.') + parser.add_option('--event', + dest='event', + action='store', + help='Event to profile. Required.') + parser.add_option('-F', + dest='sampling_frequencies', + action='append', + help='A target frequency to sample at.') + parser.add_option('-c', + dest='sampling_periods', + action='append', + help='A target period to sample at. Event specific.') + parser.add_option('--benchmark-iterations', + dest='benchmark_iterations', + action='store', + default=4, + help='Number of benchmark iters') + parser.add_option('--test-iterations', + dest='test_iterations', + action='store', + default=10, + help='Number of test iters') + parser.add_option('-p', + dest='print_only', + action='store_true', + help='If enabled, will print experiment file and exit.') + parser.add_option('--perf_options', + dest='perf_options', + action='store', + help='Arbitrary flags to perf. Surround with dblquotes.') + options = parser.parse_args()[0] + if options.remote is None: + print '%s requires a remote hostname.' % sys.argv[0] + return 1 + elif options.board is None: + print '%s requires a target board.' % sys.argv[0] + return 1 + elif options.event is None: + print '%s requires an event to profile.' % sys.argv[0] + return 1 + else: + crosperf_root = options.crosperf_root + chromeos_root = options.chromeos_root + remote = options.remote + board = options.board + event = options.event + bench_iters = options.benchmark_iterations + test_iters = options.test_iterations + perf_opts = options.perf_options + # Set up baseline test. + experiment_file = HEADER % (board, remote, bench_iters, test_iters) + # Set up experimental tests. + if options.sampling_frequencies: + for freq in options.sampling_frequencies: + test_string = str(freq) + 'Freq' + experiment_file += EXPERIMENT % (test_string, bench_iters, test_iters, + '-F %s' % freq, '' if perf_opts is None + else perf_opts, event) + if options.sampling_periods: + for period in options.sampling_periods: + test_string = str(period) + 'Period' + experiment_file += EXPERIMENT % ( + test_string, bench_iters, test_iters, '-c %s' % period, '' if + perf_opts is None else perf_opts, event) + # Point to the target image. + experiment_file += DEFAULT_IMAGE % (chromeos_root, board) + if options.print_only: + print experiment_file + else: + current_time = int(round(time.time() * 1000)) + file_name = 'perf_overhead_%s' % str(current_time) + with open(file_name, 'w') as f: + f.write(experiment_file) + try: + process = subprocess.Popen(['%s/crosperf' % crosperf_root, file_name]) + process.communicate() + except OSError: + print 'Could not find crosperf, make sure --crosperf flag is set right.' + return 1 + return 0 + + +if __name__ == '__main__': + exit(main()) |