• 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--
16create view freq_view as
17  select
18    ts,
19    lead(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts as dur,
20    cpu,
21    name as freq_name,
22    value as freq_value
23  from counter
24  inner join cpu_counter_track
25    on counter.track_id = cpu_counter_track.id
26  where name = 'cpufreq';
27
28create view idle_view
29  as select
30    ts,
31    lead(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts as dur,
32    cpu,
33    name as idle_name,
34    value as idle_value
35  from counter
36  inner join cpu_counter_track
37    on counter.track_id = cpu_counter_track.id
38  where name = 'cpuidle';
39
40create virtual table freq_idle
41  using span_join(freq_view PARTITIONED cpu, idle_view PARTITIONED cpu)
42
43create virtual table window_freq_idle using window;
44
45create virtual table span_freq_idle
46  using span_join(freq_idle PARTITIONED cpu, window_freq_idle)
47
48update window_freq_idle
49  set
50    window_start=(select min(ts) from sched),
51    window_dur=(select max(ts) - min(ts) from sched),
52    quantum=1000000
53  where rowid = 0
54
55create view counter_view
56  as select
57    ts,
58    dur,
59    quantum_ts,
60    cpu,
61    case idle_value
62      when 4294967295 then "freq"
63      else "idle"
64    end as name,
65    case idle_value
66      when 4294967295 then freq_value
67      else idle_value
68    end as value
69  from span_freq_idle
70
71select cpu, name, value, sum(dur) from counter_view group by cpu, name, value
72