File: page_loads.sql

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (110 lines) | stat: -rw-r--r-- 4,293 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
-- Copyright 2023 The Chromium Authors
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.

-- TODO(b/306300843): The recorded navigation ids are not guaranteed to be
-- unique within a trace; they are only guaranteed to be unique within a single
-- chrome instance. Chrome instance id needs to be recorded, and used here in
-- combination with navigation id to uniquely identify page load metrics.

INCLUDE PERFETTO MODULE slices.with_context;

CREATE PERFETTO VIEW _fcp_metrics AS
SELECT
  ts,
  dur,
  extract_arg(arg_set_id, 'page_load.navigation_id') AS navigation_id,
  extract_arg(arg_set_id, 'page_load.url') AS url,
  upid AS browser_upid
FROM process_slice
WHERE
  name = 'PageLoadMetrics.NavigationToFirstContentfulPaint';

CREATE PERFETTO FUNCTION _page_load_metrics(
    event_name STRING
)
RETURNS TABLE (
  ts TIMESTAMP,
  dur DURATION,
  navigation_id LONG,
  browser_upid LONG
) AS
SELECT
  ts,
  dur,
  extract_arg(arg_set_id, 'page_load.navigation_id') AS navigation_id,
  upid AS browser_upid
FROM process_slice
WHERE
  name = $event_name;

-- Chrome page loads, including associated high-level metrics and properties.
CREATE PERFETTO TABLE chrome_page_loads (
  -- ID of the navigation and Chrome browser process; this combination is
  -- unique to every individual navigation.
  id LONG,
  -- ID of the navigation associated with the page load (i.e. the cross-document
  -- navigation in primary main frame which created this page's main document).
  -- Also note that navigation_id is specific to a given Chrome browser process,
  -- and not globally unique.
  navigation_id LONG,
  -- Timestamp of the start of navigation.
  navigation_start_ts TIMESTAMP,
  -- Duration between the navigation start and the first contentful paint event
  -- (web.dev/fcp).
  fcp LONG,
  -- Timestamp of the first contentful paint.
  fcp_ts TIMESTAMP,
  -- Duration between the navigation start and the largest contentful paint event
  -- (web.dev/lcp).
  lcp LONG,
  -- Timestamp of the largest contentful paint.
  lcp_ts TIMESTAMP,
  -- Timestamp of the DomContentLoaded event:
  -- https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event
  dom_content_loaded_event_ts TIMESTAMP,
  -- Timestamp of the window load event:
  -- https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
  load_event_ts TIMESTAMP,
  -- Timestamp of the page self-reporting as fully loaded through the
  -- performance.mark('mark_fully_loaded') API.
  mark_fully_loaded_ts TIMESTAMP,
  -- Timestamp of the page self-reporting as fully visible through the
  -- performance.mark('mark_fully_visible') API.
  mark_fully_visible_ts TIMESTAMP,
  -- Timestamp of the page self-reporting as fully interactive through the
  -- performance.mark('mark_interactive') API.
  mark_interactive_ts TIMESTAMP,
  -- URL at the page load event.
  url STRING,
  -- The unique process id (upid) of the browser process where the page load occurred.
  browser_upid LONG
) AS
SELECT
  row_number() OVER (ORDER BY fcp.ts) AS id,
  fcp.navigation_id,
  fcp.ts AS navigation_start_ts,
  fcp.dur AS fcp,
  fcp.ts + fcp.dur AS fcp_ts,
  lcp.dur AS lcp,
  lcp.dur + lcp.ts AS lcp_ts,
  load_fired.ts AS dom_content_loaded_event_ts,
  start_load.ts AS load_event_ts,
  timing_loaded.ts AS mark_fully_loaded_ts,
  timing_visible.ts AS mark_fully_visible_ts,
  timing_interactive.ts AS mark_interactive_ts,
  fcp.url,
  fcp.browser_upid
FROM _fcp_metrics AS fcp
LEFT JOIN _page_load_metrics('PageLoadMetrics.NavigationToLargestContentfulPaint') AS lcp
  USING (navigation_id, browser_upid)
LEFT JOIN _page_load_metrics('PageLoadMetrics.NavigationToDOMContentLoadedEventFired') AS load_fired
  USING (navigation_id, browser_upid)
LEFT JOIN _page_load_metrics('PageLoadMetrics.NavigationToMainFrameOnLoad') AS start_load
  USING (navigation_id, browser_upid)
LEFT JOIN _page_load_metrics('PageLoadMetrics.UserTimingMarkFullyLoaded') AS timing_loaded
  USING (navigation_id, browser_upid)
LEFT JOIN _page_load_metrics('PageLoadMetrics.UserTimingMarkFullyVisible') AS timing_visible
  USING (navigation_id, browser_upid)
LEFT JOIN _page_load_metrics('PageLoadMetrics.UserTimingMarkInteractive') AS timing_interactive
  USING (navigation_id, browser_upid);