1 #!/usr/bin/env python 2 # SPDX-License-Identifier: Apache-2.0 3 # 4 # Copyright (C) 2017, ARM Limited, Google, and contributors. 5 # 6 # Licensed under the Apache License, Version 2.0 (the "License"); you may 7 # not use this file except in compliance with the License. 8 # You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 # 18 19 import logging 20 from conf import LisaLogging 21 LisaLogging.setup() 22 23 import json 24 import os 25 import devlib 26 from env import TestEnv 27 import argparse 28 29 # Setup target configuration 30 conf = { 31 # Target platform and board 32 "platform" : 'android', 33 # Useful for reading names of little/big cluster 34 # and energy model info, its device specific and use 35 # only if needed for analysis 36 # "board" : 'pixel', 37 # Device 38 # By default the device connected is detected, but if more than 1 39 # device, override the following to get a specific device. 40 # "device" : "HT66N0300080", 41 # Folder where all the results will be collected 42 "results_dir" : "BinderThroughputTest", 43 # Define devlib modules to load 44 "modules" : [ 45 'cpufreq', # enable CPUFreq support 46 'cpuidle', # enable cpuidle support 47 # 'cgroups' # Enable for cgroup support 48 ], 49 "emeter" : { 50 'instrument': 'monsoon', 51 'conf': { } 52 }, 53 "systrace": { 54 'extra_categories': ['binder_driver'], 55 "extra_events": ["binder_transaction_alloc_buf"], 56 }, 57 # Tools required by the experiments 58 "tools" : [ 'taskset'], 59 } 60 61 te = TestEnv(conf, wipe=False) 62 target = te.target 63 64 def experiment(workers, payload, iterations, cpu): 65 target.cpufreq.set_all_governors("performance") 66 cmd = "taskset -a {} /data/local/tmp/binderThroughputTest -p ".format(cpu) 67 cmd += "-s {} -i {} -w {}".format(payload, iterations, workers) 68 return target.execute(cmd) 69 70 parser = argparse.ArgumentParser( 71 description="Run binderThroughputTest and collect output.") 72 73 parser.add_argument("--test", "-t", type=str, 74 choices=["cs", "payload"], 75 default="cs", 76 help="cs: vary number of cs_pairs while control payload.\n" 77 "payload: vary payload size while control cs_pairs.") 78 parser.add_argument("--out_prefix", "-o", type=str, 79 help="The kernel image used for running the test.") 80 parser.add_argument("--cpu", "-c", type=str, 81 default='f', 82 help="cpus on which to run the tests.") 83 parser.add_argument("--iterations", "-i", type=int, 84 default=10000, 85 help="Number of iterations to run the transaction.") 86 87 parser.add_argument("--cs_pairs", type=int, nargs='+', 88 default=[1, 2, 3, 4, 5], 89 help="Varying client-server pairs.") 90 parser.add_argument("--payload", type=int, default=0, 91 help="Fixed payload in varying cs pairs.") 92 93 parser.add_argument("--payloads", type=int, nargs='+', 94 default=[0, 4096, 4096*2, 4096*4, 4096*8], 95 help="Varying payloads.") 96 parser.add_argument("--cs_pair", type=int, default=1, 97 help="Fixed single cs pair in varying payload.") 98 99 if __name__ == "__main__": 100 args = parser.parse_args() 101 102 results = [] 103 if args.test == "cs": 104 for cs in args.cs_pairs: 105 result = experiment(cs*2, args.payload, args.iterations, args.cpu) 106 results.append(result) 107 108 out_file = os.path.join(te.res_dir, 109 args.out_prefix + "_cs_" + str(args.payload)) 110 with open(out_file, 'w') as f: 111 for r in results: 112 f.write("%s\n" % r) 113 else: 114 for pl in args.payloads: 115 result = experiment(args.cs_pair*2, pl, args.iterations, args.cpu) 116 results.append(result) 117 118 out_file = os.path.join(te.res_dir, 119 args.out_prefix + \ 120 "_payload_" + str(args.cs_pair)) 121 with open(out_file, 'w') as f: 122 for r in results: 123 f.write("%s\n" % r) 124