ipython[all] will install IPython Notebook, a web based interactive python programming interface. It is required if you plan to use interactive plotting in BART.
# Setup test configuration if test_conf: if isinstance(test_conf, dict): self._log.info('Loading custom (inline) test configuration') self.test_conf = test_conf elif isinstance(test_conf, str): self._log.info('Loading custom (file) test configuration') self.test_conf = self.loadTargetConfig(test_conf) else: raise ValueError('test_conf must be either a dictionary or a filepath') self._log.debug('Test configuration %s', self.conf)
# Setup target working directory if 'workdir' in self.conf: self.workdir = self.conf['workdir']
# Initialize binary tools to deploy if 'tools' in self.conf: self.__tools = self.conf['tools'] # Merge tests specific tools if self.test_conf and 'tools' in self.test_conf and \ self.test_conf['tools']: if 'tools' not in self.conf: self.conf['tools'] = [] self.__tools = list(set( self.conf['tools'] + self.test_conf['tools'] ))
# Initialize ftrace events # test configuration override target one if self.test_conf and 'ftrace' in self.test_conf: self.conf['ftrace'] = self.test_conf['ftrace'] if 'ftrace' in self.conf and self.conf['ftrace']: self.__tools.append('trace-cmd')
# Initialize features if '__features__' not in self.conf: self.conf['__features__'] = []
A tests executor is a module which support the execution of a configured set of experiments. Each experiment is composed by: - a target configuration - a worload to execute
The executor module can be configured to run a set of workloads (wloads) in each different target configuration of a specified set (confs). These wloads and confs can be specified by the "experiments_conf" input dictionary. Each (workload, conf, iteration) tuple is called an "experiment".
All the results generated by each experiment will be collected a result folder which is named according to this template: results/<test_id>/<wltype>:<conf>:<wload>/<run_id> where: - <test_id> : the "tid" defined by the experiments_conf, or a timestamp based folder in case "tid" is not specified - <wltype> : the class of workload executed, e.g. rtapp or sched_perf - <conf> : the identifier of one of the specified configurations - <wload> : the identified of one of the specified workload - <run_id> : the progressive execution number from 1 up to the specified iterations
After the workloads have been run, the Executor object's `experiments` attribute is a list of Experiment objects. The `out_dir` attribute of these objects can be used to find the results of the experiment. """
# Run all the configured experiments exp_idx = 0 for tc in self._experiments_conf['confs']: # TARGET: configuration if not self._target_configure(tc): 配置待测设备 continue for wl_idx in self._experiments_conf['wloads']: # TEST: configuration wload, test_dir = self._wload_init(tc, wl_idx) workload初始化 for itr_idx in range(1, self._iterations + 1): exp = Experiment( wload_name=wl_idx, wload=wload, conf=tc, iteration=itr_idx, out_dir=os.path.join(test_dir, str(itr_idx))) self.experiments.append(exp)
# Setup local results folder self._log.debug('out_dir set to [%s]', experiment.out_dir) os.system('mkdir -p ' + experiment.out_dir)
# Freeze all userspace tasks that we don't need for running tests need_thaw = False if self._target_conf_flag(tc, 'freeze_userspace'): need_thaw = self._freeze_userspace()
# FTRACE: start (if a configuration has been provided) if self.te.ftrace and self._target_conf_flag(tc, 'ftrace'): self._log.warning('FTrace events collection enabled') 准备抓取ftrace self.te.ftrace.start()
# ENERGY: start sampling 抓取Power Meter数据 if self.te.emeter: self.te.emeter.reset()
# WORKLOAD: Run the configured workload wload.run(out_dir=experiment.out_dir, cgroup=self._cgroup) 执行workload
下面是收集Power Meter和ftrace数据。
# ENERGY: collect measurements if self.te.emeter: self.te.emeter.report(experiment.out_dir)
# FTRACE: stop and collect measurements if self.te.ftrace and self._target_conf_flag(tc, 'ftrace'): self.te.ftrace.stop()
critical_tasks = { 'linux': ['init', 'systemd', 'sh', 'ssh'], 'android': [ 'sh', 'adbd', 'init', 'usb', 'transport', # We don't actually need this task but on Google Pixel it apparently # cannot be frozen, so the cgroup state gets stuck in FREEZING if we # try to freeze it. 'thermal-engine' ] }
# CPUS: setup execution on CPUs if required by configuration cpus = self._wload_cpus(wl_idx, wlspec)
# CGroup: setup CGroups if requried by configuration self._cgroup = self._default_cgroup if 'cgroup' in wlspec: if 'cgroups' not in self.target.modules: raise RuntimeError('Target not supporting CGroups or CGroups ' 'not configured for the current test configuration') self._cgroup = wlspec['cgroup']
if wlspec['type'] == 'rt-app': return self._wload_rtapp(wl_idx, wlspec, cpus) rtapp类型的workload if wlspec['type'] == 'perf_bench': return self._wload_perf_bench(wl_idx, wlspec, cpus) perf_bench类型的workload
raise ValueError('unsupported "type" value for [{}] ' 'workload specification' .format(wl_idx))
{ /* Platform */ /* - linux : accessed via SSH connection */ /* - android : accessed via ADB connection */ /* - host : run on the local host */ "platform" : "android", 不同类型的Target,对应不同类型的Connection
/* Board */ /* Currently supported boards are: */ /* juno : target is a JUNO board */ /* tc2 : target is a TC2 board */ /* Leave commented if your board is not listed above */ "board" : "hikey", 主板类型对应libs/utils/platforms/hikey.json文件。
/* Target Android device ID */ "device" : "0123456789abcdef", adb设备的ID
/* Login username (has to be sudo enabled) */ "username" : "root",
…
/* Devlib modules to enable/disbale for all the experiments */ "modules" : [], "exclude_modules" : [],
…
/* List of test environment features to enable */ /* no-kernel : do not deploy kernel/dtb images */ /* no-reboot : do not force reboot the target at each */ /* configuration change */ /* debug : enable debugging messages */ "__features__" : "no-kernel no-reboot" }
# Compose the actual execution command starting from the base command # defined by the base class _command = self.command
if not _command: self._log.error('Error: empty executor command')
# Prepend eventually required taskset command if cpus or self.cpus: 如果需要设置CPU亲和性,使用taskset进行设置。 cpus_mask = self.getCpusMask(cpus if cpus else self.cpus) self.taskset_cmd = '{}/taskset 0x{:X}'\ .format(self.target.executables_directory, cpus_mask) _command = '{} {}'\ .format(self.taskset_cmd, _command)
if self.cgroup and hasattr(self.target, 'cgroups'): # Get a reference to the CGroup to use _command = self.target.cgroups.run_into_cmd(self.cgroup, _command)
# Start FTrace (if required) if ftrace: 设置ftrace相关sysfs节点,启动ftrace抓取 ftrace.start()
# Wait `start_pause` seconds before running the workload if start_pause_s: self._log.info('Waiting %f seconds before starting workload execution', start_pause_s) sleep(start_pause_s)
# Start task in background if required if background: 是否作为背景进程运行 self._log.debug('WlGen [background]: %s', _command) self.target.background(_command, as_root=as_root) self.output['executor'] = ''
# Start task in foreground else: self._log.info('Workload execution START:') self._log.info(' %s', _command) # Run command and wait for it to complete results = self.target.execute(_command, as_root=as_root) 在class TestEnv的_init_target创建了class Target的子类class AndroidTarget。此处execute都是通过adb shell执行。 self.output['executor'] = results
# Wait `end_pause` seconds before stopping ftrace if end_pause_s: self._log.info('Waiting %f seconds before stopping trace collection', end_pause_s) sleep(end_pause_s)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· .NET Core 中如何实现缓存的预热?
· 三行代码完成国际化适配,妙~啊~
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?