• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2019 The Android Open Source Project
3--
4-- Licensed under the Apache License, Version 2.0 (the "License");
5-- you may not use this file except in compliance with the License.
6-- You may obtain a copy of the License at
7--
8--     https://www.apache.org/licenses/LICENSE-2.0
9--
10-- Unless required by applicable law or agreed to in writing, software
11-- distributed under the License is distributed on an "AS IS" BASIS,
12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-- See the License for the specific language governing permissions and
14-- limitations under the License.
15--
16
17-- View of Power Rail counters with ts converted from ns to ms.
18DROP VIEW IF EXISTS power_rails_counters;
19CREATE VIEW power_rails_counters AS
20SELECT value, ts/1000000 AS ts, name
21FROM counter c
22JOIN counter_track t on c.track_id = t.id
23WHERE name LIKE 'power.%';
24
25DROP VIEW IF EXISTS power_rails_view;
26CREATE VIEW power_rails_view AS
27WITH RECURSIVE name AS (SELECT DISTINCT name FROM power_rails_counters)
28SELECT
29  name,
30  ts,
31  AndroidPowerRails_PowerRails(
32    'name', name,
33    'energy_data', RepeatedField(
34      AndroidPowerRails_EnergyData(
35        'timestamp_ms', ts,
36        'energy_uws', value
37      )
38    )
39  ) AS power_rails_proto
40FROM power_rails_counters
41GROUP BY name
42ORDER BY ts ASC;
43
44DROP VIEW IF EXISTS android_powrails_output;
45CREATE VIEW android_powrails_output AS
46SELECT AndroidPowerRails(
47  'power_rails', (
48    SELECT RepeatedField(power_rails_proto)
49    FROM power_rails_view
50  )
51);
52