• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- Copyright 2023 The Chromium Authors
2-- Use of this source code is governed by a BSD-style license that can be
3-- found in the LICENSE file.
4
5INCLUDE PERFETTO MODULE chrome.speedometer_2_1;
6INCLUDE PERFETTO MODULE chrome.speedometer_3;
7
8CREATE PERFETTO FUNCTION _chrome_speedometer_version()
9RETURNS STRING
10AS
11WITH
12  num_measures AS (
13    SELECT '2.1' AS version, COUNT(*) AS num_measures
14    FROM chrome_speedometer_2_1_measure
15    UNION ALL
16    SELECT '3' AS version, COUNT(*) AS num_measures
17    FROM chrome_speedometer_3_measure
18  )
19SELECT version
20FROM num_measures
21ORDER BY num_measures DESC
22LIMIT 1;
23
24-- Augmented slices for Speedometer measurements.
25-- These are the intervals of time Speedometer uses to compute the final score.
26-- There are two intervals that are measured for every test: sync and async
27CREATE PERFETTO TABLE chrome_speedometer_measure(
28  -- Start timestamp of the measure slice
29  ts TIMESTAMP,
30  -- Duration of the measure slice
31  dur DURATION,
32  -- Full measure name
33  name STRING,
34  -- Speedometer iteration the slice belongs to.
35  iteration LONG,
36  -- Suite name
37  suite_name STRING,
38  -- Test name
39  test_name STRING,
40  -- Type of the measure (sync or async)
41  measure_type STRING)
42AS
43WITH
44  all_versions AS (
45    SELECT '2.1' AS version, * FROM chrome_speedometer_2_1_measure
46    UNION ALL
47    SELECT '3' AS version, * FROM chrome_speedometer_3_measure
48  )
49SELECT ts, dur, name, iteration, suite_name, test_name, measure_type
50FROM all_versions
51WHERE version = _chrome_speedometer_version();
52
53-- Slice that covers one Speedometer iteration.
54-- Depending on the Speedometer version these slices might need to be estimated
55-- as older versions of Speedometer to not emit marks for this interval. The
56-- metrics associated are the same ones Speedometer would output, but note we
57-- use ns precision (Speedometer uses ~100us) so the actual values might differ
58-- a bit.
59CREATE PERFETTO TABLE chrome_speedometer_iteration(
60  -- Start timestamp of the iteration
61  ts TIMESTAMP,
62  -- Duration of the iteration
63  dur DURATION,
64  -- Iteration name
65  name STRING,
66  -- Iteration number
67  iteration LONG,
68  -- Geometric mean of the suite durations for this iteration.
69  geomean DOUBLE,
70  -- Speedometer score for this iteration (The total score for a run in the
71  -- average of all iteration scores).
72  score DOUBLE)
73AS
74WITH
75  all_versions AS (
76    SELECT '2.1' AS version, * FROM chrome_speedometer_2_1_iteration
77    UNION ALL
78    SELECT '3' AS version, * FROM chrome_speedometer_3_iteration
79  )
80SELECT ts, dur, name, iteration, geomean, score
81FROM all_versions
82WHERE version = _chrome_speedometer_version();
83
84-- Returns the Speedometer score for all iterations in the trace
85CREATE PERFETTO FUNCTION chrome_speedometer_score()
86-- Speedometer score
87RETURNS DOUBLE
88AS
89SELECT
90  IIF(
91    _chrome_speedometer_version() = '3',
92    chrome_speedometer_3_score(),
93    chrome_speedometer_2_1_score());
94
95-- Returns the utid for the main thread that ran Speedometer 3
96CREATE PERFETTO FUNCTION chrome_speedometer_renderer_main_utid()
97-- Renderer main utid
98RETURNS LONG
99AS
100SELECT
101  IIF(
102    _chrome_speedometer_version() = '3',
103    chrome_speedometer_3_renderer_main_utid(),
104    chrome_speedometer_2_1_renderer_main_utid());
105