Commit 4bda9f96 authored by perezju's avatar perezju Committed by Commit bot

Make single shell call in _SetScalingGovernorInternal

Changed implementation to make a single shell call, rather than
pushing files and executing several shell calls.

When running telemetry unittests on android, reduces total execution
time about 12%.

BUG=379378

Review URL: https://codereview.chromium.org/514123005

Cr-Commit-Position: refs/heads/master@{#292405}
parent fd033701
......@@ -68,12 +68,13 @@ class PerfControl(object):
self._ForceAllCpusOnline(False)
def _SetScalingGovernorInternal(self, value):
for cpu in range(self._num_cpu_cores):
scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu
if self._device.FileExists(scaling_governor_file):
logging.info('Writing scaling governor mode \'%s\' -> %s',
value, scaling_governor_file)
self._device.WriteFile(scaling_governor_file, value, as_root=True)
cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)])
script = ('for CPU in %s; do\n'
' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n'
' test -e $FILE && echo %s > $FILE\n'
'done\n') % (cpu_cores, value)
logging.info('Setting scaling governor mode: %s', value)
self._device.RunShellCommand(script, as_root=True)
def _AllCpusAreOnline(self):
for cpu in range(self._num_cpu_cores):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment