diff options
author | Yan Wang <yawanng@google.com> | 2019-07-31 01:55:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-07-31 01:55:33 +0000 |
commit | 313328dcde5c40fa1a2af413bb66f4a03ce3068c (patch) | |
tree | 3477d28fc47e75f0880d4f97f8c919625d44d3a2 /startop/scripts/app_startup/app_startup_runner.py | |
parent | 875161c6baa730e554d5f8db7ea73da71e236669 (diff) | |
parent | 06f54882c06da4b3090f2edfe321c07b1a7ec2a6 (diff) |
Merge "startop: Refactor app running."
Diffstat (limited to 'startop/scripts/app_startup/app_startup_runner.py')
-rwxr-xr-x | startop/scripts/app_startup/app_startup_runner.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/startop/scripts/app_startup/app_startup_runner.py b/startop/scripts/app_startup/app_startup_runner.py index 7cba7805903d..7b3bf3387452 100755 --- a/startop/scripts/app_startup/app_startup_runner.py +++ b/startop/scripts/app_startup/app_startup_runner.py @@ -33,12 +33,12 @@ import os import sys import tempfile from typing import Any, Callable, Iterable, List, NamedTuple, TextIO, Tuple, \ - TypeVar, Union + TypeVar, Union, Optional # local import DIR = os.path.abspath(os.path.dirname(__file__)) sys.path.append(os.path.dirname(DIR)) -import app_startup.run_app_with_prefetch as run_app_with_prefetch +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 import lib.cmd_utils as cmd_utils @@ -62,6 +62,16 @@ _COLLECTOR_TIMEOUT_MULTIPLIER = 10 # take the regular --timeout and multiply _UNLOCK_SCREEN_SCRIPT = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'unlock_screen') +RunCommandArgs = NamedTuple('RunCommandArgs', + [('package', str), + ('readahead', str), + ('activity', Optional[str]), + ('compiler_filter', Optional[str]), + ('timeout', Optional[int]), + ('debug', bool), + ('simulate', bool), + ('input', Optional[str])]) + # This must be the only mutable global variable. All other global variables are constants to avoid magic literals. _debug = False # See -d/--debug flag. _DEBUG_FORCE = None # Ignore -d/--debug if this is not none. @@ -207,8 +217,7 @@ def parse_run_script_csv_file(csv_file: TextIO) -> DataFrame: return DataFrame(d) def execute_run_combos( - grouped_run_combos: Iterable[Tuple[CollectorPackageInfo, Iterable[ - run_app_with_prefetch.RunCommandArgs]]], + grouped_run_combos: Iterable[Tuple[CollectorPackageInfo, Iterable[RunCommandArgs]]], simulate: bool, inodes_path: str, timeout: int): @@ -229,7 +238,7 @@ def execute_run_combos( combos = combos._replace(input=collector_tmp_output_file.name) print_utils.debug_print(combos) - output = run_app_with_prefetch.run_test(combos) + output = PrefetchAppRunner(**combos._asdict()).run() yield DataFrame(dict((x, [y]) for x, y in output)) if output else None @@ -307,7 +316,7 @@ def main(): output_file = opts.output and open(opts.output, 'w') or sys.stdout combos = lambda: args_utils.generate_run_combinations( - run_app_with_prefetch.RunCommandArgs, + RunCommandArgs, coerce_to_list(vars(opts)), opts.loop_count) print_utils.debug_print_gen("run combinations: ", combos()) |