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

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: Support startup performance tests on Galaxy S3 - code review fixes 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 def __init__(self, adb): 135 def __init__(self, adb):
136 self._adb = adb 136 self._adb = adb
137 kernel_max = self._adb.GetFileContents('/sys/devices/system/cpu/kernel_max', 137 kernel_max = self._adb.GetFileContents('/sys/devices/system/cpu/kernel_max',
138 log_result=False) 138 log_result=False)
139 assert kernel_max, 'Unable to find /sys/devices/system/cpu/kernel_max' 139 assert kernel_max, 'Unable to find /sys/devices/system/cpu/kernel_max'
140 self._kernel_max = int(kernel_max[0]) 140 self._kernel_max = int(kernel_max[0])
141 self._original_scaling_governor = None 141 self._original_scaling_governor = None
142 142
143 def DropRamCaches(self): 143 def DropRamCaches(self):
144 """Drops the filesystem ram caches for performance testing.""" 144 """Drops the filesystem ram caches for performance testing."""
145 if not self._adb.IsRootEnabled(): 145 self._adb.RunShellCommand('su -c sync')
146 self._adb.EnableAdbRoot() 146 self._adb.SetProtectedFileContents(PerfTestSetup._DROP_CACHES, '3')
147 self._adb.RunShellCommand('sync')
148 self._adb.RunShellCommand('echo 3 > ' + PerfTestSetup._DROP_CACHES)
149 147
150 def SetUp(self): 148 def SetUp(self):
151 """Sets up performance tests.""" 149 """Sets up performance tests."""
152 if not self._original_scaling_governor: 150 if not self._original_scaling_governor:
153 self._original_scaling_governor = self._adb.GetFileContents( 151 self._original_scaling_governor = self._adb.GetFileContents(
154 PerfTestSetup._SCALING_GOVERNOR_FMT % 0, 152 PerfTestSetup._SCALING_GOVERNOR_FMT % 0,
155 log_result=False)[0] 153 log_result=False)[0]
156 self._SetScalingGovernorInternal('performance') 154 self._SetScalingGovernorInternal('performance')
157 self.DropRamCaches() 155 self.DropRamCaches()
158 156
159 def TearDown(self): 157 def TearDown(self):
160 """Tears down performance tests.""" 158 """Tears down performance tests."""
161 if self._original_scaling_governor: 159 if self._original_scaling_governor:
162 self._SetScalingGovernorInternal(self._original_scaling_governor) 160 self._SetScalingGovernorInternal(self._original_scaling_governor)
163 self._original_scaling_governor = None 161 self._original_scaling_governor = None
164 162
165 def _SetScalingGovernorInternal(self, value): 163 def _SetScalingGovernorInternal(self, value):
166 for cpu in range(self._kernel_max + 1): 164 for cpu in range(self._kernel_max + 1):
167 scaling_governor_file = PerfTestSetup._SCALING_GOVERNOR_FMT % cpu 165 scaling_governor_file = PerfTestSetup._SCALING_GOVERNOR_FMT % cpu
168 if self._adb.Adb().DoesFileExist(scaling_governor_file): 166 if self._adb.FileExistsOnDevice(scaling_governor_file):
169 self._adb.RunShellCommand( 167 self._adb.SetProtectedFileContents(scaling_governor_file, value)
170 ('echo %s > ' + scaling_governor_file) % value)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698