def run(self, out_dir, duration_s, collect=''): """ Run single idle/suspend workload. :param out_dir: Path to experiment directory where to store results. :type out_dir: str :param duration_s: Duration of test :type duration_s: int :type force: str :param collect: Specifies what to collect. Possible values: - 'energy' - 'systrace' - 'ftrace' - any combination of the above :type collect: list(str) """ # Idle/resume should always disconnect USB so rely on # the Energy meter to disconnect USB (We only support USB disconnect # mode for energy measurement, like with Monsoon if 'energy' not in collect: collect = collect + ' energy' # Keep track of mandatory parameters self.out_dir = out_dir self.collect = collect # Set min brightness Screen.set_brightness(self._target, auto=False, percent=0) # Set timeout to min value Screen.set_timeout(self._target, seconds=0) # Prevent screen from dozing Screen.set_doze_always_on(self._target, on=False) # Turn on airplane mode System.set_airplane_mode(self._target, on=True) # Unlock device screen (assume no password required) Screen.unlock(self._target) # Force the device to suspend System.force_suspend_start(self._target) # Prevent the device from fully suspending by holding a partial wakelock System.wakelock(self._target, take=True) sleep(1) Screen.set_screen(self._target, on=False) sleep(1) self.tracingStart(screen_always_on=False) self._log.info('Waiting for duration {}'.format(duration_s)) sleep(duration_s) self.tracingStop(screen_always_on=False) # Resume normal function System.force_suspend_stop(self._target) # Release wakelock System.wakelock(self._target, take=False) Screen.set_defaults(self._target) System.set_airplane_mode(self._target, on=False)
def experiment(): # Check if the dhyrstone binary is on the device dhrystone = os.path.join(target.executables_directory, 'dhrystone') if not target.file_exists(dhrystone): raise RuntimeError('dhrystone could not be located here: {}'.format( dhrystone)) # Create results directory outdir=te.res_dir + '_' + args.out_prefix if not args.cont: try: shutil.rmtree(outdir) except: print "couldn't remove " + outdir pass if not os.path.exists(outdir): os.makedirs(outdir) # Get clusters and cpus cpus = [cpu for cluster in CLUSTERS for cpu in cluster] # Prevent screen from dozing Screen.set_doze_always_on(target, on=False) # Turn on airplane mode System.set_airplane_mode(target, on=True) # Turn off screen Screen.set_screen(target, on=False) # Stop thermal engine and perfd target.execute("stop thermal-engine") target.execute("stop perfd") # Take a wakelock System.wakelock(target, take=True) # Store governors so they can be restored later governors = [ target.cpufreq.get_governor(cpu) for cpu in cpus] # Set the governer to userspace so the cpu frequencies can be set target.hotplug.online_all() target.cpufreq.set_all_governors('userspace') # Freeze all non critical tasks target.cgroups.freeze(exclude=CRITICAL_TASKS) # Remove all userspace tasks from the cluster sandbox_cg, isolated_cg = target.cgroups.isolate([]) # Run measurements on single cluster single_cluster(cpus, sandbox_cg, isolated_cg, dhrystone, outdir) # Run measurements on multiple clusters multiple_clusters(cpus, sandbox_cg, isolated_cg, dhrystone, outdir) # Restore all governors for i, governor in enumerate(governors): target.cpufreq.set_governor(cpus[i], governor) # Restore non critical tasks target.cgroups.freeze(thaw=True) # Release wakelock System.wakelock(target, take=False) # Stop thermal engine and perfd target.execute("start thermal-engine") target.execute("start perfd") # Dump platform te.platform_dump(outdir) te._log.info('RESULTS are in out directory: {}'.format(outdir))