blob: 5058d16dc60a7c9d47a2cd6efd93edc72af81ffa [file] [log] [blame]
Ionela Voinescu5910b642017-01-27 13:11:37 +00001#!/usr/bin/python
2
3import os
4from time import sleep
5
6# The workload class MUST be loaded before the LisaBenchmark
7from android import Workload
8from android import LisaBenchmark
9
10from devlib.exception import TargetError
11
12class UiBenchTest(LisaBenchmark):
13
14 bm_conf = {
15
16 # Target platform and board
17 "platform" : 'android',
18
19 # Define devlib modules to load
20 "modules" : [
21 'cpufreq',
22 ],
23
24 # FTrace events to collect for all the tests configuration which have
25 # the "ftrace" flag enabled
26 "ftrace" : {
27 "events" : [
28 "sched_switch",
29 "sched_overutilized",
30 "sched_contrib_scale_f",
31 "sched_load_avg_cpu",
32 "sched_load_avg_task",
33 "sched_tune_tasks_update",
34 "sched_boost_cpu",
35 "sched_boost_task",
36 "sched_energy_diff",
37 "cpu_frequency",
38 "cpu_idle",
39 "cpu_capacity",
40 ],
41 "buffsize" : 10 * 1024,
42 },
43
44 # Default EnergyMeter Configuration
45 "emeter" : {
46 "instrument" : "acme",
47 "channel_map" : {
48 "Device0" : 0,
49 }
50 },
51
52 # Tools required by the experiments
53 "tools" : [ 'trace-cmd' ],
54
55 # Default results folder
56 "results_dir" : "AndroidUiBench",
57
58 }
59
60 # Android Workload to run
61 bm_name = 'UiBench'
62
63 # Default products to be collected
64 bm_collect = 'ftrace energy'
65
66 def benchmarkInit(self):
67 self.setupWorkload()
68 self.setupGovernor()
Ionela Voinescu5910b642017-01-27 13:11:37 +000069
Juri Lelli6604ad22017-04-14 15:30:16 +010070 def __init__(self, governor, test, duration_s):
Ionela Voinescu5910b642017-01-27 13:11:37 +000071 self.governor = governor
72 self.test = test
73 self.duration_s = duration_s
Ionela Voinescu5910b642017-01-27 13:11:37 +000074 super(UiBenchTest, self).__init__()
75
76 def setupWorkload(self):
77 # Create a results folder for each "governor/test"
78 self.out_dir = os.path.join(self.te.res_dir, governor, self.test)
79 try:
80 os.stat(self.out_dir)
81 except:
82 os.makedirs(self.out_dir)
83 # Setup workload parameters
84 self.bm_params = {
85 'test_name' : self.test,
86 'duration_s' : self.duration_s,
87 }
88
89 def setupGovernor(self):
90 try:
91 self.target.cpufreq.set_all_governors(self.governor);
92 except TargetError:
93 self._log.warning('Governor [%s] not available on target',
94 self.governor)
95 raise
96
97 # Setup schedutil parameters
98 if self.governor == 'schedutil':
99 rate_limit_us = 2000
100 # Different schedutil versions have different tunables
101 tunables = self.target.cpufreq.list_governor_tunables(0)
102 if 'rate_limit_us' in tunables:
103 tunables = {'rate_limit_us' : str(rate_limit_us)}
104 else:
105 assert ('up_rate_limit_us' in tunables and
106 'down_rate_limit_us' in tunables)
107 tunables = {
108 'up_rate_limit_us' : str(rate_limit_us),
109 'down_rate_limit_us' : str(rate_limit_us)
110 }
111
112 try:
113 for cpu_id in range(self.te.platform['cpus_count']):
114 self.target.cpufreq.set_governor_tunables(
115 cpu_id, 'schedutil', **tunables)
116 except TargetError as e:
117 self._log.warning('Failed to set schedutils parameters: {}'\
118 .format(e))
119 raise
120 self._log.info('Set schedutil.rate_limit_us=%d', rate_limit_us)
121
122 # Setup ondemand parameters
123 if self.governor == 'ondemand':
124 try:
125 for cpu_id in range(self.te.platform['cpus_count']):
126 tunables = self.target.cpufreq.get_governor_tunables(cpu_id)
127 self.target.cpufreq.set_governor_tunables(
128 cpu_id, 'ondemand',
129 **{'sampling_rate' : tunables['sampling_rate_min']})
130 except TargetError as e:
131 self._log.warning('Failed to set ondemand parameters: {}'\
132 .format(e))
133 raise
134 self._log.info('Set ondemand.sampling_rate to minimum supported')
135
136 # Report configured governor
137 governors = self.target.cpufreq.get_all_governors()
138 self._log.info('Using governors: %s', governors)
139
140# Run the benchmark in each of the supported governors
141
142duration_s = 20
143
144governors = [
145 'performance',
146 'ondemand',
147 'interactive',
148 'sched',
149 'schedutil',
150 'powersave',
151]
152
153tests = [
Michael McGeagh899b58a2017-03-09 15:05:35 +0000154# General
155 'DialogListActivity',
156 'FullscreenOverdrawActivity',
157 'GlTextureViewActivity',
158 'InvalidateActivity',
159 'TrivialAnimationActivity',
160 'TrivialListActivity',
161 'TrivialRecyclerViewActivity',
162# Inflation
163 'InflatingListActivity',
164# Rendering
165 'BitmapUploadActivity',
166 'ShadowGridActivity',
167# Text
168 'EditTextTypeActivity',
169 'TextCacheHighHitrateActivity',
170 'TextCacheLowHitrateActivity',
171# Transitions
172 'ActivityTransition',
173 'ActivityTransitionDetails',
Ionela Voinescu5910b642017-01-27 13:11:37 +0000174]
175
Ionela Voinescu5910b642017-01-27 13:11:37 +0000176tests_remaining = len(governors) * len(tests)
177tests_completed = 0
178for governor in governors:
179 for test in tests:
180 tests_remaining -= 1
Ionela Voinescu5910b642017-01-27 13:11:37 +0000181 try:
Juri Lelli6604ad22017-04-14 15:30:16 +0100182 UiBenchTest(governor, test, duration_s)
Ionela Voinescu5910b642017-01-27 13:11:37 +0000183 tests_completed += 1
184 except:
185 # A test configuraion failed, continue with other tests
186 pass
Ionela Voinescu5910b642017-01-27 13:11:37 +0000187
188# We want to collect data from at least one governor
189assert(tests_completed >= 1)
190
191# vim :set tabstop=4 shiftwidth=4 expandtab