diff options
author | Anton Kirilov <anton.kirilov@linaro.org> | 2016-08-05 16:19:52 +0100 |
---|---|---|
committer | Anton Kirilov <anton.kirilov@linaro.org> | 2016-08-18 11:29:28 +0100 |
commit | 8078467184aa769f5131c2d09863e44ddecb2d5e (patch) | |
tree | 2d5b635b59ccadd0a7578255ed390a68232d9bbe | |
parent | a9255fb53d0e2baba1b0f191acccceec9c52d5ba (diff) | |
download | art-testing-8078467184aa769f5131c2d09863e44ddecb2d5e.tar.gz |
Compilation statistics with alternate Android root
Change-Id: I43b48fdcd805821d06737dfdf83207614d9a21f4
-rwxr-xr-x | tools/benchmarks/run.py | 18 | ||||
-rwxr-xr-x | tools/compilation_statistics/run.py | 26 | ||||
-rw-r--r-- | tools/utils.py | 21 |
3 files changed, 43 insertions, 22 deletions
diff --git a/tools/benchmarks/run.py b/tools/benchmarks/run.py index 6d0cc6b..d2ca88e 100755 --- a/tools/benchmarks/run.py +++ b/tools/benchmarks/run.py @@ -82,23 +82,15 @@ def BuildBenchmarks(build_for_target): def RunBenchADB(mode, compiler_mode, android_root, auto_calibrate, apk, classname, target): - format_data={'workdir': os.path.dirname(apk), 'rootpath': android_root, - 'mode': {"":"", "32":"", "64":"64"}[mode] } + format_data = {'workdir': os.path.dirname(apk)} + path, env, runtime_param = utils.GetAndroidRootConfiguration(android_root, mode == '64') # Escaping through `adb shell` is fiddly, so we expand the path fully in # the environment configuration. - environment_config = 'ANDROID_DATA={workdir} DEX_LOCATION={workdir}' - dalvikvm = 'dalvikvm%s' % mode - dalvikvm_options = '' + environment_config = env + ' ANDROID_DATA={workdir} DEX_LOCATION={workdir}' + dalvikvm = path + 'dalvikvm%s' % mode + dalvikvm_options = ' '.join(runtime_param) apk_arguments = '' - if android_root: - # Add additional options. - environment_config = "ANDROID_ROOT={rootpath} " + environment_config - environment_config += " LD_LIBRARY_PATH={rootpath}/lib{mode}" - dalvikvm = android_root + '/bin/' + dalvikvm - # Note ART will expand this to -Ximage:/data/art-test/${arch}/core.art - dalvikvm_options += ' -Ximage:/data/art-test/core.art' - dalvikvm_options += ' -Xbootclasspath:{rootpath}/framework/core-libart.jar' if auto_calibrate: # Run the benchmark's time* method(s) via bench_runner_main apk_arguments += " %s %s" % (bench_runner_main, classname) diff --git a/tools/compilation_statistics/run.py b/tools/compilation_statistics/run.py index 4541e94..153f461 100755 --- a/tools/compilation_statistics/run.py +++ b/tools/compilation_statistics/run.py @@ -71,10 +71,14 @@ def GetStats(apk, target, isa, compiler_mode, + android_root, target_copy_path, iterations, work_dir, boot_oat_file): + path, env, runtime_param = utils.GetAndroidRootConfiguration(android_root, isa.endswith('64')) + dex2oat = os.path.join(path, 'dex2oat') + if boot_oat_file: oat = "%s/boot.%s.oat" % (target_copy_path, isa) art = "%s/boot.%s.art" % (target_copy_path, isa) @@ -114,22 +118,27 @@ def GetStats(apk, # Replace destination: --oat-file, fix beginning of command. command = re.sub("--oat-file=(.+?) --", "--oat-file=%s --" % oat, command) command = re.sub("--image=(.+?) --", "--image=%s --" % art, command) - command = re.sub("dex2oat-cmdline +=", "dex2oat", command) + command = re.sub("dex2oat-cmdline +=", dex2oat, command) # Force 1 thread only - we want compilation times to be as stable as possible and we are # interested in single thread performance, not multi-thread (throughput). command = re.sub(" -j\d+ ", " -j1 ", command) # Remove newline at end. command = re.sub("\n$", "", command) - command = '(echo $BASHPID && exec ' + command + ' ) | head -n1' + command = '(echo $BASHPID && ' + env + ' exec ' + command + ') | head -n1' else: + runtime_arguments = ' --runtime-arg -Xnorelocate ' + + for param in runtime_param: + runtime_arguments += '--runtime-arg ' + param + ' ' + apk_path = os.path.join(target_copy_path, apk) oat = apk_path + '.' + isa + '.oat' dex2oat_options = utils.GetDex2oatOptions(compiler_mode) # Only the output of the first command is necessary; execute in a subshell # to guarantee PID value; only one thread is used for compilation to reduce # measurement noise. - command = '(echo $BASHPID && exec dex2oat -j1 --runtime-arg -Xnorelocate ' + \ - ' '.join(dex2oat_options) + \ + command = '(echo $BASHPID && ' + env + ' exec ' + dex2oat + \ + ' -j1' + runtime_arguments + ' '.join(dex2oat_options) + \ ' --dex-file=' + apk_path + ' --oat-file=' + oat command += ' --instruction-set=' + isa + ') | head -n1' @@ -237,14 +246,13 @@ def GetCompilationStatisticsResults(args): for apk in sorted(apk_list): if apk[:8] == "boot.oat": - res[apk] = GetStats(apk, args.target, isa, - args.compiler_mode, args.target_copy_path, - args.iterations, work_dir, boot_oat_file) + res[apk] = GetStats(apk, args.target, isa, args.compiler_mode, args.android_root, + args.target_copy_path, args.iterations, work_dir, boot_oat_file) else: utils_adb.push(apk, args.target_copy_path, args.target) apk_name = os.path.basename(apk) - res[apk_name] = GetStats(apk_name, args.target, isa, - args.compiler_mode, args.target_copy_path, + res[apk_name] = GetStats(apk_name, args.target, isa, args.compiler_mode, + args.android_root, args.target_copy_path, args.iterations, work_dir, None) shutil.rmtree(work_dir) diff --git a/tools/utils.py b/tools/utils.py index 46bb743..ff6f7c6 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -215,6 +215,27 @@ def GetDex2oatOptions(compiler_mode): return options +def GetAndroidRootConfiguration(android_root, is_64bit): + path = '' + environment = '' + runtime_parameters = [] + + if android_root: + path = android_root + '/bin/' + environment = 'ANDROID_ROOT=' + android_root + library_path = ' LD_LIBRARY_PATH=' + android_root + '/lib' + + if is_64bit: + environment += library_path + '64' + else: + environment += library_path + + # Note ART will expand this to -Ximage:/data/art-test/${arch}/core.art. + runtime_parameters = ['-Ximage:/data/art-test/core.art'] + runtime_parameters += ['-Xbootclasspath:' + android_root + '/framework/core-libart.jar'] + + return path, environment, runtime_parameters + default_output_formats = ['json', 'pkl'] def OutputObject(object, format, output_filename): |