Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 import android_commands | 7 import android_commands |
| 8 import json | 8 import json |
| 9 import math | 9 import math |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 _EscapePerfResult(measurement), | 116 _EscapePerfResult(measurement), |
| 117 value) | 117 value) |
| 118 avg, sd = GeomMeanAndStdDevFromHistogram(value) | 118 avg, sd = GeomMeanAndStdDevFromHistogram(value) |
| 119 | 119 |
| 120 if avg: | 120 if avg: |
| 121 output += '\nAvg %s: %f%s' % (measurement, avg, units) | 121 output += '\nAvg %s: %f%s' % (measurement, avg, units) |
| 122 if sd: | 122 if sd: |
| 123 output += '\nSd %s: %f%s' % (measurement, sd, units) | 123 output += '\nSd %s: %f%s' % (measurement, sd, units) |
| 124 if print_to_stdout: | 124 if print_to_stdout: |
| 125 print output | 125 print output |
| 126 import sys | |
|
bulach
2013/01/16 17:23:26
probably more common to import in the header as us
marja
2013/01/16 17:25:26
Done.
| |
| 127 sys.stdout.flush() | |
| 126 return output | 128 return output |
| 127 | 129 |
| 128 | 130 |
| 129 class PerfTestSetup(object): | 131 class PerfTestSetup(object): |
| 130 """Provides methods for setting up a device for perf testing.""" | 132 """Provides methods for setting up a device for perf testing.""" |
| 131 _DROP_CACHES = '/proc/sys/vm/drop_caches' | 133 _DROP_CACHES = '/proc/sys/vm/drop_caches' |
| 132 _SCALING_GOVERNOR_FMT = ( | 134 _SCALING_GOVERNOR_FMT = ( |
| 133 '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor') | 135 '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor') |
| 134 | 136 |
| 135 def __init__(self, adb): | 137 def __init__(self, adb): |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 161 if self._original_scaling_governor: | 163 if self._original_scaling_governor: |
| 162 self._SetScalingGovernorInternal(self._original_scaling_governor) | 164 self._SetScalingGovernorInternal(self._original_scaling_governor) |
| 163 self._original_scaling_governor = None | 165 self._original_scaling_governor = None |
| 164 | 166 |
| 165 def _SetScalingGovernorInternal(self, value): | 167 def _SetScalingGovernorInternal(self, value): |
| 166 for cpu in range(self._kernel_max + 1): | 168 for cpu in range(self._kernel_max + 1): |
| 167 scaling_governor_file = PerfTestSetup._SCALING_GOVERNOR_FMT % cpu | 169 scaling_governor_file = PerfTestSetup._SCALING_GOVERNOR_FMT % cpu |
| 168 if self._adb.Adb().DoesFileExist(scaling_governor_file): | 170 if self._adb.Adb().DoesFileExist(scaling_governor_file): |
| 169 self._adb.RunShellCommand( | 171 self._adb.RunShellCommand( |
| 170 ('echo %s > ' + scaling_governor_file) % value) | 172 ('echo %s > ' + scaling_governor_file) % value) |
| OLD | NEW |