• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2024 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
16INCLUDE PERFETTO MODULE counters.intervals;
17
18-- Counter information for each frequency change for each CPU. Finds each time
19-- region where a CPU frequency is constant.
20CREATE PERFETTO TABLE cpu_freq_counters(
21  -- Counter id.
22  id INT,
23  -- Joinable with 'counter_track.id'.
24  track_id INT,
25  -- Starting timestamp of the counter
26  ts LONG,
27  -- Duration in which counter is constant and frequency doesn't change.
28  dur INT,
29  -- Frequency in kHz of the CPU that corresponds to this counter. NULL if not
30  -- found or undefined.
31  freq INT,
32  -- CPU that corresponds to this counter.
33  cpu INT
34) AS
35SELECT
36  count_w_dur.id,
37  count_w_dur.track_id,
38  count_w_dur.ts,
39  count_w_dur.dur,
40  cast_int!(count_w_dur.value) as freq,
41  cct.cpu
42FROM
43counter_leading_intervals!((
44  SELECT c.*
45  FROM counter c
46  JOIN cpu_counter_track cct
47  ON cct.id = c.track_id AND cct.name = 'cpufreq'
48)) count_w_dur
49JOIN cpu_counter_track cct
50ON track_id = cct.id;
51
52