1*da0073e9SAndroid Build Coastguard Worker"""Basic runner for the instruction count microbenchmarks. 2*da0073e9SAndroid Build Coastguard Worker 3*da0073e9SAndroid Build Coastguard WorkerThe contents of this file are placeholders, and will be replaced by more 4*da0073e9SAndroid Build Coastguard Workerexpressive and robust components (e.g. better runner and result display 5*da0073e9SAndroid Build Coastguard Workercomponents) in future iterations. However this allows us to excercise the 6*da0073e9SAndroid Build Coastguard Workerunderlying benchmark generation infrastructure in the mean time. 7*da0073e9SAndroid Build Coastguard Worker""" 8*da0073e9SAndroid Build Coastguard Worker# mypy: ignore-errors 9*da0073e9SAndroid Build Coastguard Workerimport argparse 10*da0073e9SAndroid Build Coastguard Workerimport sys 11*da0073e9SAndroid Build Coastguard Workerfrom typing import List 12*da0073e9SAndroid Build Coastguard Worker 13*da0073e9SAndroid Build Coastguard Workerfrom applications import ci 14*da0073e9SAndroid Build Coastguard Workerfrom core.expand import materialize 15*da0073e9SAndroid Build Coastguard Workerfrom definitions.standard import BENCHMARKS 16*da0073e9SAndroid Build Coastguard Workerfrom execution.runner import Runner 17*da0073e9SAndroid Build Coastguard Workerfrom execution.work import WorkOrder 18*da0073e9SAndroid Build Coastguard Worker 19*da0073e9SAndroid Build Coastguard Worker 20*da0073e9SAndroid Build Coastguard Workerdef main(argv: List[str]) -> None: 21*da0073e9SAndroid Build Coastguard Worker work_orders = tuple( 22*da0073e9SAndroid Build Coastguard Worker WorkOrder(label, autolabels, timer_args, timeout=600, retries=2) 23*da0073e9SAndroid Build Coastguard Worker for label, autolabels, timer_args in materialize(BENCHMARKS) 24*da0073e9SAndroid Build Coastguard Worker ) 25*da0073e9SAndroid Build Coastguard Worker 26*da0073e9SAndroid Build Coastguard Worker results = Runner(work_orders).run() 27*da0073e9SAndroid Build Coastguard Worker for work_order in work_orders: 28*da0073e9SAndroid Build Coastguard Worker print( 29*da0073e9SAndroid Build Coastguard Worker work_order.label, 30*da0073e9SAndroid Build Coastguard Worker work_order.autolabels, 31*da0073e9SAndroid Build Coastguard Worker work_order.timer_args.num_threads, 32*da0073e9SAndroid Build Coastguard Worker results[work_order].instructions, 33*da0073e9SAndroid Build Coastguard Worker ) 34*da0073e9SAndroid Build Coastguard Worker 35*da0073e9SAndroid Build Coastguard Worker 36*da0073e9SAndroid Build Coastguard Workerif __name__ == "__main__": 37*da0073e9SAndroid Build Coastguard Worker modes = { 38*da0073e9SAndroid Build Coastguard Worker "debug": main, 39*da0073e9SAndroid Build Coastguard Worker "ci": ci.main, 40*da0073e9SAndroid Build Coastguard Worker } 41*da0073e9SAndroid Build Coastguard Worker 42*da0073e9SAndroid Build Coastguard Worker parser = argparse.ArgumentParser() 43*da0073e9SAndroid Build Coastguard Worker parser.add_argument("--mode", type=str, choices=list(modes.keys()), default="debug") 44*da0073e9SAndroid Build Coastguard Worker 45*da0073e9SAndroid Build Coastguard Worker args, remaining_args = parser.parse_known_args(sys.argv) 46*da0073e9SAndroid Build Coastguard Worker modes[args.mode](remaining_args[1:]) 47