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