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

Side by Side Diff: tools/skpbench/_hardware_pixel_c.py

Issue 2481413003: skpbench: simplify adb and reduce number of invocations (Closed)
Patch Set: skpbench: simplify adb and reduce number of invocations Created 4 years, 1 month 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
« no previous file with comments | « tools/skpbench/_hardware_nexus_6p.py ('k') | tools/skpbench/skpbench.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 Google Inc. 1 # Copyright 2016 Google Inc.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 from _hardware import HardwareException, Expectation 6 from _hardware import HardwareException, Expectation
7 from _hardware_android import HardwareAndroid 7 from _hardware_android import HardwareAndroid
8 8
9 CPU_CLOCK_RATE = 1836000 9 CPU_CLOCK_RATE = 1836000
10 GPU_EMC_PROFILE = '0c: core 921 MHz emc 1600 MHz a A d D *' 10 GPU_EMC_PROFILE = '0c: core 921 MHz emc 1600 MHz a A d D *'
11 GPU_EMC_PROFILE_ID = '0c' 11 GPU_EMC_PROFILE_ID = '0c'
12 12
13 class HardwarePixelC(HardwareAndroid): 13 class HardwarePixelC(HardwareAndroid):
14 def __init__(self, adb): 14 def __init__(self, adb):
15 HardwareAndroid.__init__(self, adb) 15 HardwareAndroid.__init__(self, adb)
16 16
17 def __enter__(self): 17 def __enter__(self):
18 self._lock_clocks() 18 self._lock_clocks()
19 return HardwareAndroid.__enter__(self) 19 return HardwareAndroid.__enter__(self)
20 20
21 def __exit__(self, exception_type, exception_value, exception_traceback): 21 def __exit__(self, exception_type, exception_value, exception_traceback):
22 HardwareAndroid.__exit__(self, exception_type, 22 HardwareAndroid.__exit__(self, exception_type,
23 exception_value, exception_traceback) 23 exception_value, exception_traceback)
24 self._unlock_clocks() 24 self._unlock_clocks()
25 25
26 def _lock_clocks(self): 26 def _lock_clocks(self):
27 if not self._is_root: 27 if not self._adb.is_root():
28 return 28 return
29 29
30 # lock cpu clocks. 30 self._adb.shell('\n'.join([
31 self._adb.shell('''\ 31 # lock cpu clocks.
32 '''
32 for N in $(seq 0 3); do 33 for N in $(seq 0 3); do
33 echo userspace > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_governor 34 echo userspace > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_governor
34 echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_setspeed 35 echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_setspeed
35 done''' % CPU_CLOCK_RATE) 36 done''' % CPU_CLOCK_RATE,
36 37
37 # lock gpu/emc clocks. 38 # lock gpu/emc clocks.
38 self._adb.shell('''\ 39 '''
39 chown root:root /sys/devices/57000000.gpu/pstate 40 chown root:root /sys/devices/57000000.gpu/pstate
40 echo %s > /sys/devices/57000000.gpu/pstate''' % GPU_EMC_PROFILE_ID) 41 echo %s > /sys/devices/57000000.gpu/pstate''' % GPU_EMC_PROFILE_ID]))
41 42
42 def _unlock_clocks(self): 43 def _unlock_clocks(self):
43 if not self._is_root: 44 if not self._adb.is_root():
44 return 45 return
45 46
46 # unlock gpu/emc clocks. 47 self._adb.shell('\n'.join([
47 self._adb.shell('''\ 48 # unlock gpu/emc clocks.
49 '''
48 echo auto > /sys/devices/57000000.gpu/pstate 50 echo auto > /sys/devices/57000000.gpu/pstate
49 chown system:system /sys/devices/57000000.gpu/pstate''') 51 chown system:system /sys/devices/57000000.gpu/pstate''',
50 52
51 # unlock cpu clocks. 53 # unlock cpu clocks.
52 self._adb.shell('''\ 54 '''
53 for N in $(seq 0 3); do 55 for N in $(seq 0 3); do
54 echo 0 > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_setspeed 56 echo 0 > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_setspeed
55 echo interactive > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_governo r 57 echo interactive >/sys/devices/system/cpu/cpu$N/cpufreq/scaling_governor
56 done''') 58 done''']))
57 59
58 def sanity_check(self): 60 def sanity_check(self):
59 HardwareAndroid.sanity_check(self) 61 HardwareAndroid.sanity_check(self)
60 62
61 if not self._is_root: 63 if not self._adb.is_root():
62 return 64 return
63 65
64 # only issue one shell command in an attempt to minimize interference. 66 # only issue one shell command in an attempt to minimize interference.
65 result = self._adb.check_lines('''\ 67 result = self._adb.check('''\
66 cat /sys/class/power_supply/bq27742-0/capacity \ 68 cat /sys/class/power_supply/bq27742-0/capacity \
67 /sys/class/thermal/thermal_zone7/temp \ 69 /sys/class/thermal/thermal_zone7/temp \
68 /sys/class/thermal/thermal_zone0/temp \ 70 /sys/class/thermal/thermal_zone0/temp \
69 /sys/class/thermal/thermal_zone1/temp \ 71 /sys/class/thermal/thermal_zone1/temp \
70 /sys/class/thermal/thermal_zone7/cdev1/cur_state \ 72 /sys/class/thermal/thermal_zone7/cdev1/cur_state \
71 /sys/class/thermal/thermal_zone7/cdev0/cur_state 73 /sys/class/thermal/thermal_zone7/cdev0/cur_state
72 for N in $(seq 0 3); do 74 for N in $(seq 0 3); do
73 cat /sys/devices/system/cpu/cpu$N/cpufreq/scaling_cur_freq 75 cat /sys/devices/system/cpu/cpu$N/cpufreq/scaling_cur_freq
74 done 76 done
75 cat /sys/devices/57000000.gpu/pstate | grep \*$''') 77 cat /sys/devices/57000000.gpu/pstate | grep \*$''')
76 78
77 expectations = \ 79 expectations = \
78 [Expectation(int, min_value=30, name='battery', sleeptime=30*60), 80 [Expectation(int, min_value=30, name='battery', sleeptime=30*60),
79 Expectation(int, max_value=40000, name='skin temperature'), 81 Expectation(int, max_value=40000, name='skin temperature'),
80 Expectation(int, max_value=86000, name='cpu temperature'), 82 Expectation(int, max_value=86000, name='cpu temperature'),
81 Expectation(int, max_value=87000, name='gpu temperature'), 83 Expectation(int, max_value=87000, name='gpu temperature'),
82 Expectation(int, exact_value=0, name='cpu throttle'), 84 Expectation(int, exact_value=0, name='cpu throttle'),
83 Expectation(int, exact_value=0, name='gpu throttle')] + \ 85 Expectation(int, exact_value=0, name='gpu throttle')] + \
84 [Expectation(int, exact_value=CPU_CLOCK_RATE, 86 [Expectation(int, exact_value=CPU_CLOCK_RATE,
85 name='cpu_%i clock rate' % i, sleeptime=30) 87 name='cpu_%i clock rate' % i, sleeptime=30)
86 for i in range(4)] + \ 88 for i in range(4)] + \
87 [Expectation(str, exact_value=GPU_EMC_PROFILE, name='gpu/emc profile')] 89 [Expectation(str, exact_value=GPU_EMC_PROFILE, name='gpu/emc profile')]
88 90
89 Expectation.check_all(expectations, result) 91 Expectation.check_all(expectations, result.splitlines())
90 92
91 def sleep(self, sleeptime): 93 def sleep(self, sleeptime):
92 self._unlock_clocks() 94 self._unlock_clocks()
93 HardwareAndroid.sleep(self, sleeptime) 95 HardwareAndroid.sleep(self, sleeptime)
94 self._lock_clocks() 96 self._lock_clocks()
OLDNEW
« no previous file with comments | « tools/skpbench/_hardware_nexus_6p.py ('k') | tools/skpbench/skpbench.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698