diff options
author | Yan Wang <yawanng@google.com> | 2019-09-06 16:19:03 -0700 |
---|---|---|
committer | Yan Wang <yawanng@google.com> | 2019-09-10 11:47:23 -0700 |
commit | 75015c32eb2f3cc890c6aabd49d0508a471166cd (patch) | |
tree | 2934ec61d6f90d964164bfeb3c036afb74e2f804 /startop/scripts/app_startup/app_startup_runner.py | |
parent | 18206aecea314e08bc7040c4127a815652d6f755 (diff) |
startop: add compiler type support to host and device switch.
When using device, the python modules for host are not loaded to be
compatiable in tradefed.
Test: pytest
Test: python app_startup_runner.py --package com.google.android.GoogleCamera --readahead fadvise --inodes textcache --output output.txt -lc 1 -d
Change-Id: I9fe54045fbabda5f66ebe1cfe6d0a5461fff0640
Diffstat (limited to 'startop/scripts/app_startup/app_startup_runner.py')
-rwxr-xr-x | startop/scripts/app_startup/app_startup_runner.py | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/startop/scripts/app_startup/app_startup_runner.py b/startop/scripts/app_startup/app_startup_runner.py index eb582f946958..fa1c4e601f83 100755 --- a/startop/scripts/app_startup/app_startup_runner.py +++ b/startop/scripts/app_startup/app_startup_runner.py @@ -41,11 +41,12 @@ DIR = os.path.abspath(os.path.dirname(__file__)) sys.path.append(os.path.dirname(DIR)) import lib.cmd_utils as cmd_utils import lib.print_utils as print_utils -import iorap.compiler as compiler from app_startup.run_app_with_prefetch import PrefetchAppRunner import app_startup.lib.args_utils as args_utils from app_startup.lib.data_frame import DataFrame from app_startup.lib.perfetto_trace_collector import PerfettoTraceCollector +from iorap.compiler import CompilerType +import iorap.compiler as compiler # The following command line options participate in the combinatorial generation. # All other arguments have a global effect. @@ -58,8 +59,6 @@ _RUN_SCRIPT = os.path.join(os.path.dirname(os.path.realpath(__file__)), CollectorPackageInfo = NamedTuple('CollectorPackageInfo', [('package', str), ('compiler_filter', str)]) -_COMPILER_SCRIPT = os.path.join(os.path.dirname(os.path.dirname( - os.path.realpath(__file__))), 'iorap/compiler.py') # by 2; systrace starts up slowly. _UNLOCK_SCREEN_SCRIPT = os.path.join( @@ -135,6 +134,10 @@ def parse_options(argv: List[str] = None): action='append', help='The trace duration (milliseconds) in ' 'compilation') + optional_named.add_argument('--compiler-type', dest='compiler_type', + type=CompilerType, choices=list(CompilerType), + default=CompilerType.DEVICE, + help='The type of compiler.') return parser.parse_args(argv) @@ -211,26 +214,26 @@ def parse_run_script_csv_file(csv_file: TextIO) -> DataFrame: return DataFrame(d) -def compile_perfetto_trace(inodes_path: str, +def build_ri_compiler_argv(inodes_path: str, perfetto_trace_file: str, - trace_duration: Optional[timedelta]) -> TextIO: - compiler_trace_file = tempfile.NamedTemporaryFile() - argv = [_COMPILER_SCRIPT, '-i', inodes_path, '--perfetto-trace', - perfetto_trace_file, '-o', compiler_trace_file.name] + trace_duration: Optional[timedelta] + ) -> str: + argv = ['-i', inodes_path, '--perfetto-trace', + perfetto_trace_file] if trace_duration is not None: argv += ['--duration', str(int(trace_duration.total_seconds() - * PerfettoTraceCollector.MS_PER_SEC))] + * PerfettoTraceCollector.MS_PER_SEC))] print_utils.debug_print(argv) - compiler.main(argv) - return compiler_trace_file + return argv def execute_run_using_perfetto_trace(collector_info, run_combos: Iterable[RunCommandArgs], simulate: bool, inodes_path: str, - timeout: int) -> DataFrame: + timeout: int, + compiler_type: CompilerType) -> DataFrame: """ Executes run based on perfetto trace. """ passed, perfetto_trace_file = run_perfetto_collector(collector_info, timeout, @@ -244,9 +247,15 @@ def execute_run_using_perfetto_trace(collector_info, if simulate: compiler_trace_file = tempfile.NamedTemporaryFile() else: - compiler_trace_file = compile_perfetto_trace(inodes_path, - perfetto_trace_file.name, - combos.trace_duration) + ri_compiler_argv = build_ri_compiler_argv(inodes_path, + perfetto_trace_file.name, + combos.trace_duration) + compiler_trace_file = compiler.compile(compiler_type, + inodes_path, + ri_compiler_argv, + combos.package, + combos.activity) + with compiler_trace_file: combos = combos._replace(input=compiler_trace_file.name) print_utils.debug_print(combos) @@ -261,7 +270,8 @@ def execute_run_combos( grouped_run_combos: Iterable[Tuple[CollectorPackageInfo, Iterable[RunCommandArgs]]], simulate: bool, inodes_path: str, - timeout: int): + timeout: int, + compiler_type: CompilerType): # nothing will work if the screen isn't unlocked first. cmd_utils.execute_arbitrary_command([_UNLOCK_SCREEN_SCRIPT], timeout, @@ -273,7 +283,8 @@ def execute_run_combos( run_combos, simulate, inodes_path, - timeout) + timeout, + compiler_type) def gather_results(commands: Iterable[Tuple[DataFrame]], key_list: List[str], value_list: List[Tuple[str, ...]]): @@ -361,7 +372,8 @@ def main(): exec = execute_run_combos(grouped_combos(), opts.simulate, opts.inodes, - opts.timeout) + opts.timeout, + opts.compiler_type) results = gather_results(exec, _COMBINATORIAL_OPTIONS, combos()) |