1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#!/usr/bin/env python3
# Copyright (C) 2023 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License a
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from python.generators.diff_tests.testing import Path, DataPath, Metric
from python.generators.diff_tests.testing import Csv, Json, TextProto
from python.generators.diff_tests.testing import DiffTestBlueprint
from python.generators.diff_tests.testing import TestSuite
class PowerPowerRails(TestSuite):
def test_power_rails_power_rails(self):
return DiffTestBlueprint(
trace=DataPath('power_rails.pb'),
query="""
SELECT name, AVG(value), COUNT(*)
FROM counters
WHERE name GLOB "power.*"
GROUP BY name
LIMIT 20;
""",
out=Csv("""
"name","AVG(value)","COUNT(*)"
"power.PPVAR_VPH_PWR_ABH_uws",7390700.360656,61
"power.PPVAR_VPH_PWR_OLED_uws",202362991.655738,61
"""))
def test_power_rails_event_power_rails_custom_clock(self):
return DiffTestBlueprint(
trace=Path('power_rails_custom_clock.textproto'),
query="""
SELECT ts, value
FROM counters
WHERE name GLOB "power.*"
LIMIT 20;
""",
out=Csv("""
"ts","value"
104000000,333.000000
106000000,666.000000
106000000,999.000000
109000000,0.000000
"""))
def test_power_rails_timestamp_sort(self):
return DiffTestBlueprint(
trace=Path('power_rails.textproto'),
query="""
SELECT ts, value, t.name AS name
FROM counter c JOIN counter_track t ON t.id = c.track_id
ORDER BY ts
LIMIT 20;
""",
out=Csv("""
"ts","value","name"
3000000,333.000000,"power.test_rail_uws"
3000000,0.000000,"power.test_rail_uws"
3000004,1000.000000,"Testing"
3000005,999.000000,"power.test_rail2_uws"
5000000,666.000000,"power.test_rail_uws"
"""))
def test_power_rails_well_known_power_rails(self):
return DiffTestBlueprint(
trace=TextProto(r"""
packet {
power_rails {
rail_descriptor {
index: 4
rail_name: "S3M_VDD_CPUCL1"
subsys_name: "cpu"
sampling_rate: 1023
}
}
}
packet {
timestamp: 3000003
power_rails {
energy_data {
index: 4
timestamp_ms: 3
energy: 333
}
}
}
packet {
timestamp: 3000005
power_rails {
rail_descriptor {
index: 3
rail_name: "S2S_VDD_G3D"
subsys_name: "gpu"
sampling_rate: 1022
}
energy_data {
index: 4
timestamp_ms: 5
energy: 666
}
energy_data {
index: 3
energy: 999
}
energy_data {
index: 4
timestamp_ms: 3
energy: 0
}
}
}
"""),
query="""
SELECT name, AVG(value), COUNT(*)
FROM counters
WHERE name GLOB "power.*"
GROUP BY name
LIMIT 20;
""",
out=Csv("""
"name","AVG(value)","COUNT(*)"
"power.rails.cpu.mid",333.000000,3
"power.rails.gpu",999.000000,1
"""))
|