• 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
16INCLUDE PERFETTO MODULE android.startup.startup_events;
17
18CREATE PERFETTO VIEW _startup_async_events AS
19SELECT
20  ts,
21  dur,
22  cast_int!(SUBSTR(name, 19) ) AS startup_id
23FROM slice
24WHERE
25  name GLOB 'launchingActivity#*' AND dur > 0 AND instr(name, ':') = 0;
26
27CREATE PERFETTO VIEW _startup_complete_events AS
28SELECT
29  cast_int!(STR_SPLIT(completed, ':', 0)) AS startup_id,
30  str_split(completed, ':', 2) AS package_name,
31  CASE
32    WHEN str_split(completed, ':', 1) = 'completed-hot'
33    THEN 'hot'
34    WHEN str_split(completed, ':', 1) = 'completed-warm'
35    THEN 'warm'
36    WHEN str_split(completed, ':', 1) = 'completed-cold'
37    THEN 'cold'
38    ELSE NULL
39  END AS startup_type,
40  min(ts)
41FROM (
42  SELECT
43    ts,
44    substr(name, 19) AS completed
45  FROM slice
46  WHERE
47    dur = 0
48    -- Originally completed was unqualified, but at some point we introduced
49    -- the startup type as well
50    AND name GLOB 'launchingActivity#*:completed*:*'
51    AND NOT name GLOB '*:completed-same-process:*'
52)
53GROUP BY
54  1,
55  2,
56  3;
57
58CREATE PERFETTO TABLE _startups_minsdk33 AS
59SELECT
60  startup_id,
61  ts,
62  ts + dur AS ts_end,
63  dur,
64  package_name AS package,
65  startup_type
66FROM _startup_async_events
67JOIN _startup_complete_events
68  USING (startup_id);
69