blob: a5b4e172c82583d0514ce326b06a8e46c98fbc87 [file] [log] [blame]
Ionela Voinescube0e4a32017-02-02 18:26: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 VellamoTest(LisaBenchmark):
13
Ionela Voinescube0e4a32017-02-02 18:26:37 +000014 # Android Workload to run
15 bm_name = 'Vellamo'
16
17 # Default products to be collected
18 bm_collect = 'ftrace energy'
19
20 def benchmarkInit(self):
21 self.setupWorkload()
22 self.setupGovernor()
Ionela Voinescube0e4a32017-02-02 18:26:37 +000023
Juri Lelli6604ad22017-04-14 15:30:16 +010024 def __init__(self, governor, test):
Ionela Voinescube0e4a32017-02-02 18:26:37 +000025 self.governor = governor
26 self.test = test
Ionela Voinescube0e4a32017-02-02 18:26:37 +000027 super(VellamoTest, self).__init__()
28
29 def setupWorkload(self):
30 # Create a results folder for each "governor/test"
31 self.out_dir = os.path.join(self.te.res_dir, governor, self.test)
32 try:
33 os.stat(self.out_dir)
34 except:
35 os.makedirs(self.out_dir)
36 # Setup workload parameters
37 self.bm_params = {
38 'test_name' : self.test
39 }
40
41 def setupGovernor(self):
42 try:
43 self.target.cpufreq.set_all_governors(self.governor);
44 except TargetError:
45 self._log.warning('Governor [%s] not available on target',
46 self.governor)
47 raise
48
49 # Setup schedutil parameters
50 if self.governor == 'schedutil':
51 rate_limit_us = 2000
52 # Different schedutil versions have different tunables
53 tunables = self.target.cpufreq.list_governor_tunables(0)
54 if 'rate_limit_us' in tunables:
55 tunables = {'rate_limit_us' : str(rate_limit_us)}
56 else:
57 assert ('up_rate_limit_us' in tunables and
58 'down_rate_limit_us' in tunables)
59 tunables = {
60 'up_rate_limit_us' : str(rate_limit_us),
61 'down_rate_limit_us' : str(rate_limit_us)
62 }
63
64 try:
65 for cpu_id in range(self.te.platform['cpus_count']):
66 self.target.cpufreq.set_governor_tunables(
67 cpu_id, 'schedutil', **tunables)
68 except TargetError as e:
69 self._log.warning('Failed to set schedutils parameters: {}'\
70 .format(e))
71 raise
72 self._log.info('Set schedutil.rate_limit_us=%d', rate_limit_us)
73
74 # Setup ondemand parameters
75 if self.governor == 'ondemand':
76 try:
77 for cpu_id in range(self.te.platform['cpus_count']):
78 tunables = self.target.cpufreq.get_governor_tunables(cpu_id)
79 self.target.cpufreq.set_governor_tunables(
80 cpu_id, 'ondemand',
81 **{'sampling_rate' : tunables['sampling_rate_min']})
82 except TargetError as e:
83 self._log.warning('Failed to set ondemand parameters: {}'\
84 .format(e))
85 raise
86 self._log.info('Set ondemand.sampling_rate to minimum supported')
87
88 # Report configured governor
89 governors = self.target.cpufreq.get_all_governors()
90 self._log.info('Using governors: %s', governors)
91
92
93# Run the benchmark in each of the supported governors
94
95governors = [
96 'performance',
97 'ondemand',
98 'interactive',
99 'sched',
100 'schedutil',
101 'powersave'
102]
103
104tests = [
105 'BROWSER',
106 'METAL',
107 'MULTI'
108]
109
110
Ionela Voinescube0e4a32017-02-02 18:26:37 +0000111tests_remaining = len(governors) * len(tests)
112tests_completed = 0
113for governor in governors:
114 for test in tests:
115 tests_remaining -= 1
Ionela Voinescube0e4a32017-02-02 18:26:37 +0000116 try:
Juri Lelli6604ad22017-04-14 15:30:16 +0100117 VellamoTest(governor, test)
Ionela Voinescube0e4a32017-02-02 18:26:37 +0000118 tests_completed += 1
119 except:
120 # A test configuraion failed, continue with other tests
121 pass
Ionela Voinescube0e4a32017-02-02 18:26:37 +0000122
123# We want to collect data from at least one governor
124assert(tests_completed >= 1)
125
126# vim :set tabstop=4 shiftwidth=4 expandtab