Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: build/android/pylib/perf_tests_helper.py

Issue 11876021: Support startup performance tests on Galaxy S3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: S3 startup performance tests - fixes to file_changer Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 class PerfTestSetup(object): 126 class PerfTestSetup(object):
127 """Provides methods for setting up a device for perf testing.""" 127 """Provides methods for setting up a device for perf testing."""
128 _DROP_CACHES = '/proc/sys/vm/drop_caches' 128 _DROP_CACHES = '/proc/sys/vm/drop_caches'
129 _SCALING_GOVERNOR = '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor' 129 _SCALING_GOVERNOR = '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor'
130 130
131 def __init__(self, adb): 131 def __init__(self, adb):
132 self._adb = adb 132 self._adb = adb
133 num_cpus = self._adb.GetFileContents('/sys/devices/system/cpu/online', 133 num_cpus = self._adb.GetFileContents('/sys/devices/system/cpu/online',
134 log_result=False) 134 log_result=False)
135 assert num_cpus, 'Unable to find /sys/devices/system/cpu/online' 135 assert num_cpus, 'Unable to find /sys/devices/system/cpu/online'
136 self._num_cpus = int(num_cpus[0].split('-')[-1]) 136 self._num_cpus = int(re.findall(r'\d+', num_cpus[0])[-1])
137 self._original_scaling_governor = None 137 self._original_scaling_governor = None
138 138
139 def DropRamCaches(self): 139 def DropRamCaches(self):
140 """Drops the filesystem ram caches for performance testing.""" 140 """Drops the filesystem ram caches for performance testing."""
141 if not self._adb.IsRootEnabled(): 141 self._adb.RunShellCommand('su -c sync')
142 self._adb.EnableAdbRoot() 142 self._adb.RunShellCommand('su -c echo 3 > ' + PerfTestSetup._DROP_CACHES)
143 self._adb.RunShellCommand('sync')
144 self._adb.RunShellCommand('echo 3 > ' + PerfTestSetup._DROP_CACHES)
145 143
146 def SetUp(self): 144 def SetUp(self):
147 """Sets up performance tests.""" 145 """Sets up performance tests."""
148 if not self._original_scaling_governor: 146 if not self._original_scaling_governor:
149 self._original_scaling_governor = self._adb.GetFileContents( 147 self._original_scaling_governor = self._adb.GetFileContents(
150 PerfTestSetup._SCALING_GOVERNOR % 0, 148 PerfTestSetup._SCALING_GOVERNOR % 0,
151 log_result=False)[0] 149 log_result=False)[0]
152 self._SetScalingGovernorInternal('performance') 150 self._SetScalingGovernorInternal('performance')
153 self.DropRamCaches() 151 self.DropRamCaches()
154 152
155 def TearDown(self): 153 def TearDown(self):
156 """Tears down performance tests.""" 154 """Tears down performance tests."""
157 if self._original_scaling_governor: 155 if self._original_scaling_governor:
158 self._SetScalingGovernorInternal(self._original_scaling_governor) 156 self._SetScalingGovernorInternal(self._original_scaling_governor)
159 self._original_scaling_governor = None 157 self._original_scaling_governor = None
160 158
161 def _SetScalingGovernorInternal(self, value): 159 def _SetScalingGovernorInternal(self, value):
162 for cpu in range(self._num_cpus): 160 for cpu in range(self._num_cpus):
163 self._adb.RunShellCommand( 161 self._adb.RunShellCommand(
164 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu)) 162 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu))
OLDNEW
« build/android/pylib/flag_changer.py ('K') | « build/android/pylib/flag_changer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698