blob: d8b1af391b99f1b3c27e70283ffff8c0a156f52b [file] [log] [blame]
Chris Redpath02caf0f2017-02-02 17:29:03 +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 GeekbenchTest(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" : "AndroidGeekbench",
57
58 }
59
60 # Android Workload to run
61 bm_name = 'Geekbench'
62
63 # Default products to be collected
64 bm_collect = 'ftrace energy'
65
66 def benchmarkInit(self):
67 self.setupWorkload()
68 self.setupGovernor()
Chris Redpath02caf0f2017-02-02 17:29:03 +000069
Juri Lelli6604ad22017-04-14 15:30:16 +010070 def __init__(self, governor, test):
Chris Redpath02caf0f2017-02-02 17:29:03 +000071 self.governor = governor
72 self.test = test
Chris Redpath02caf0f2017-02-02 17:29:03 +000073 super(GeekbenchTest, self).__init__()
74
75 def setupWorkload(self):
76 # Create a results folder for each "governor/test"
77 self.out_dir = os.path.join(self.te.res_dir, governor)
78 try:
79 os.stat(self.out_dir)
80 except:
81 os.makedirs(self.out_dir)
82 # Setup workload parameters
83 self.bm_params = {
84 'test_name' : self.test
85 }
86
87 def setupGovernor(self):
88 try:
89 self.target.cpufreq.set_all_governors(self.governor);
90 except TargetError:
91 self._log.warning('Governor [%s] not available on target',
92 self.governor)
93 raise
94
95 # Setup schedutil parameters
96 if self.governor == 'schedutil':
97 rate_limit_us = 2000
98 # Different schedutil versions have different tunables
99 tunables = self.target.cpufreq.list_governor_tunables(0)
100 if 'rate_limit_us' in tunables:
101 tunables = {'rate_limit_us' : str(rate_limit_us)}
102 else:
103 assert ('up_rate_limit_us' in tunables and
104 'down_rate_limit_us' in tunables)
105 tunables = {
106 'up_rate_limit_us' : str(rate_limit_us),
107 'down_rate_limit_us' : str(rate_limit_us)
108 }
109
110 try:
111 for cpu_id in range(self.te.platform['cpus_count']):
112 self.target.cpufreq.set_governor_tunables(
113 cpu_id, 'schedutil', **tunables)
114 except TargetError as e:
115 self._log.warning('Failed to set schedutils parameters: {}'\
116 .format(e))
117 raise
118 self._log.info('Set schedutil.rate_limit_us=%d', rate_limit_us)
119
120 # Setup ondemand parameters
121 if self.governor == 'ondemand':
122 try:
123 for cpu_id in range(self.te.platform['cpus_count']):
124 tunables = self.target.cpufreq.get_governor_tunables(cpu_id)
125 self.target.cpufreq.set_governor_tunables(
126 cpu_id, 'ondemand',
127 **{'sampling_rate' : tunables['sampling_rate_min']})
128 except TargetError as e:
129 self._log.warning('Failed to set ondemand parameters: {}'\
130 .format(e))
131 raise
132 self._log.info('Set ondemand.sampling_rate to minimum supported')
133
134 # Report configured governor
135 governors = self.target.cpufreq.get_all_governors()
136 self._log.info('Using governors: %s', governors)
137
138# Run the benchmark in each of the supported governors
139
140governors = [
141 'performance',
142 'ondemand',
143 'interactive',
144 'sched',
145 'schedutil',
146 'powersave',
147]
148
149tests = [
150 'CPU',
151 'COMPUTE'
152]
153
Chris Redpath02caf0f2017-02-02 17:29:03 +0000154tests_remaining = len(governors) * len(tests)
155tests_completed = 0
156for governor in governors:
157 for test in tests:
158 tests_remaining -= 1
Chris Redpath02caf0f2017-02-02 17:29:03 +0000159 try:
Juri Lelli6604ad22017-04-14 15:30:16 +0100160 GeekbenchTest(governor, test)
Chris Redpath02caf0f2017-02-02 17:29:03 +0000161 tests_completed += 1
162 except:
163 # A test configuraion failed, continue with other tests
164 pass
Chris Redpath02caf0f2017-02-02 17:29:03 +0000165
166# We want to collect data from at least one governor
167assert(tests_completed >= 1)
168
169# vim :set tabstop=4 shiftwidth=4 expandtab