• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2021 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-- Collect page-reported events for each renderer. Note that we don't need to
18-- match up process ids, because the unique nav_id ensures we're only comparing
19-- corresponding events.
20
21DROP VIEW IF EXISTS page_reported_events;
22CREATE VIEW page_reported_events AS
23SELECT ts, name, EXTRACT_ARG(arg_set_id, "debug.data.navigationId") AS nav_id
24FROM slice
25WHERE category = 'blink.user_timing'
26  AND (name = 'navigationStart' OR name GLOB 'telemetry:reported_by_page:*')
27ORDER BY nav_id, ts ASC;
28
29--------------------------------------------------------------------------------
30-- Compute the duration from the corresponding navigation start for each
31-- reported event.
32
33DROP VIEW IF EXISTS page_reported_durations;
34CREATE VIEW page_reported_durations AS
35SELECT p.name, (p.ts - (
36    SELECT MAX(ts) FROM page_reported_events
37    WHERE
38      nav_id = p.nav_id
39      AND ts < p.ts AND (
40        -- Viewable/interactive markers measure time from nav start.
41        (p.name GLOB 'telemetry:reported_by_page:*'
42         AND p.name NOT GLOB 'telemetry:reported_by_page:benchmark*'
43         AND name = 'navigationStart')
44        -- Benchmark end markers measure time from the most recent begin marker.
45        OR (p.name = 'telemetry:reported_by_page:benchmark_end'
46            AND name = 'telemetry:reported_by_page:benchmark_begin')
47      ))
48) / 1e6 AS dur_ms
49FROM page_reported_events p;
50
51--------------------------------------------------------------------------------
52-- Combine results into the output table.
53
54DROP VIEW IF EXISTS reported_by_page_output;
55CREATE VIEW reported_by_page_output AS
56SELECT ReportedByPage(
57  'time_to_viewable', (
58    SELECT RepeatedField(dur_ms) FROM page_reported_durations
59    WHERE name = 'telemetry:reported_by_page:viewable'),
60  'time_to_interactive', (
61    SELECT RepeatedField(dur_ms) FROM page_reported_durations
62    WHERE name = 'telemetry:reported_by_page:interactive'),
63  'benchmark_time', (
64    SELECT RepeatedField(dur_ms) FROM page_reported_durations
65    WHERE name = 'telemetry:reported_by_page:benchmark_end')
66);
67