• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- Copyright 2024 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
5-- List Speedometer 3 measures. Used to find relevant slices.
6CREATE PERFETTO VIEW _chrome_speedometer_3_measure_name(
7  -- Expected slice name
8  name STRING,
9  -- Suite name
10  suite_name STRING,
11  -- Test name
12  test_name STRING,
13  -- Measure type
14  measure_type STRING)
15AS
16WITH
17  data(suite_name, test_name)
18  AS (
19    VALUES('TodoMVC-JavaScript-ES5', 'Adding100Items'),
20    ('TodoMVC-JavaScript-ES5', 'CompletingAllItems'),
21    ('TodoMVC-JavaScript-ES5', 'DeletingAllItems'),
22    ('TodoMVC-JavaScript-ES6-Webpack-Complex-DOM', 'Adding100Items'),
23    ('TodoMVC-JavaScript-ES6-Webpack-Complex-DOM', 'CompletingAllItems'),
24    ('TodoMVC-JavaScript-ES6-Webpack-Complex-DOM', 'DeletingAllItems'),
25    ('TodoMVC-WebComponents', 'Adding100Items'),
26    ('TodoMVC-WebComponents', 'CompletingAllItems'),
27    ('TodoMVC-WebComponents', 'DeletingAllItems'),
28    ('TodoMVC-React-Complex-DOM', 'Adding100Items'),
29    ('TodoMVC-React-Complex-DOM', 'CompletingAllItems'),
30    ('TodoMVC-React-Complex-DOM', 'DeletingAllItems'),
31    ('TodoMVC-React-Redux', 'Adding100Items'),
32    ('TodoMVC-React-Redux', 'CompletingAllItems'),
33    ('TodoMVC-React-Redux', 'DeletingAllItems'),
34    ('TodoMVC-Backbone', 'Adding100Items'),
35    ('TodoMVC-Backbone', 'CompletingAllItems'),
36    ('TodoMVC-Backbone', 'DeletingAllItems'),
37    ('TodoMVC-Angular-Complex-DOM', 'Adding100Items'),
38    ('TodoMVC-Angular-Complex-DOM', 'CompletingAllItems'),
39    ('TodoMVC-Angular-Complex-DOM', 'DeletingAllItems'),
40    ('TodoMVC-Vue', 'Adding100Items'),
41    ('TodoMVC-Vue', 'CompletingAllItems'),
42    ('TodoMVC-Vue', 'DeletingAllItems'),
43    ('TodoMVC-jQuery', 'Adding100Items'),
44    ('TodoMVC-jQuery', 'CompletingAllItems'),
45    ('TodoMVC-jQuery', 'DeletingAllItems'),
46    ('TodoMVC-Preact-Complex-DOM', 'Adding100Items'),
47    ('TodoMVC-Preact-Complex-DOM', 'CompletingAllItems'),
48    ('TodoMVC-Preact-Complex-DOM', 'DeletingAllItems'),
49    ('TodoMVC-Svelte-Complex-DOM', 'Adding100Items'),
50    ('TodoMVC-Svelte-Complex-DOM', 'CompletingAllItems'),
51    ('TodoMVC-Svelte-Complex-DOM', 'DeletingAllItems'),
52    ('TodoMVC-Lit-Complex-DOM', 'Adding100Items'),
53    ('TodoMVC-Lit-Complex-DOM', 'CompletingAllItems'),
54    ('TodoMVC-Lit-Complex-DOM', 'DeletingAllItems'),
55    ('NewsSite-Next', 'NavigateToUS'),
56    ('NewsSite-Next', 'NavigateToWorld'),
57    ('NewsSite-Next', 'NavigateToPolitics'),
58    ('NewsSite-Nuxt', 'NavigateToUS'),
59    ('NewsSite-Nuxt', 'NavigateToWorld'),
60    ('NewsSite-Nuxt', 'NavigateToPolitics'),
61    ('Editor-CodeMirror', 'Long'),
62    ('Editor-CodeMirror', 'Highlight'),
63    ('Editor-TipTap', 'Long'),
64    ('Editor-TipTap', 'Highlight'),
65    ('Charts-observable-plot', 'Stacked by 6'),
66    ('Charts-observable-plot', 'Stacked by 20'),
67    ('Charts-observable-plot', 'Dotted'),
68    ('Charts-chartjs', 'Draw scatter'),
69    ('Charts-chartjs', 'Show tooltip'),
70    ('Charts-chartjs', 'Draw opaque scatter'),
71    ('React-Stockcharts-SVG', 'Render'),
72    ('React-Stockcharts-SVG', 'PanTheChart'),
73    ('React-Stockcharts-SVG', 'ZoomTheChart'),
74    ('Perf-Dashboard', 'Render'),
75    ('Perf-Dashboard', 'SelectingPoints'),
76    ('Perf-Dashboard', 'SelectingRange')
77  ),
78  measure_type(measure_type) AS (VALUES('sync'), ('async'))
79SELECT
80  suite_name || '.' || test_name || '-' || measure_type AS name,
81  suite_name,
82  test_name,
83  measure_type
84FROM data, measure_type;
85
86CREATE PERFETTO VIEW _chrome_speedometer_3_iteration_slice
87AS
88WITH
89  data AS (
90    SELECT *, substr(name, 1 + length('iteration-')) AS iteration_str
91    FROM slice
92    WHERE category = 'blink.user_timing' AND name GLOB 'iteration-*'
93  )
94SELECT *, cast_int!(iteration_str) AS iteration
95FROM data
96WHERE iteration_str = iteration;
97
98-- Augmented slices for Speedometer measurements.
99-- These are the intervals of time Speedometer uses to compute the final score.
100-- There are two intervals that are measured for every test: sync and async.
101CREATE PERFETTO TABLE chrome_speedometer_3_measure(
102  -- Start timestamp of the measure slice
103  ts TIMESTAMP,
104  -- Duration of the measure slice
105  dur DURATION,
106  -- Full measure name
107  name STRING,
108  -- Speedometer iteration the slice belongs to.
109  iteration LONG,
110  -- Suite name
111  suite_name STRING,
112  -- Test name
113  test_name STRING,
114  -- Type of the measure (sync or async)
115  measure_type STRING)
116AS
117WITH
118  measure_slice AS (
119    SELECT s.ts, s.dur, s.name, m.suite_name, m.test_name, m.measure_type
120    FROM slice s, _chrome_speedometer_3_measure_name AS m
121    USING (name)
122    WHERE s.category = 'blink.user_timing'
123  )
124SELECT
125  s.ts, s.dur, s.name, i.iteration, s.suite_name, s.test_name, s.measure_type
126FROM measure_slice AS s, _chrome_speedometer_3_iteration_slice i
127ON (s.ts >= i.ts AND s.ts < i.ts + i.dur)
128ORDER BY s.ts ASC;
129
130-- Slice that covers one Speedometer iteration.
131-- The metrics associated are the same ones
132-- Speedometer would output, but note we use ns precision (Speedometer uses
133-- ~100us) so the actual values might differ a bit.
134CREATE PERFETTO TABLE chrome_speedometer_3_iteration(
135  -- Start timestamp of the iteration
136  ts TIMESTAMP,
137  -- Duration of the iteration
138  dur DURATION,
139  -- Iteration name
140  name STRING,
141  -- Iteration number
142  iteration LONG,
143  -- Geometric mean of the suite durations for this iteration.
144  geomean DOUBLE,
145  -- Speedometer score for this iteration (The total score for a run in the
146  -- average of all iteration scores).
147  score DOUBLE)
148AS
149WITH
150  suite AS (
151    SELECT iteration, suite_name, SUM(dur / (1000.0 * 1000.0)) AS suite_total
152    FROM chrome_speedometer_3_measure
153    GROUP BY iteration, suite_name
154  ),
155  iteration AS (
156    SELECT
157      iteration,
158      -- Compute geometric mean using LN instead of multiplication to prevent
159      -- overflows
160      EXP(AVG(LN(suite_total))) AS geomean
161    FROM suite
162    GROUP BY iteration
163  )
164SELECT s.ts, s.dur, s.name, i.iteration, i.geomean, 1000.0 / i.geomean AS score
165FROM iteration AS i, _chrome_speedometer_3_iteration_slice AS s
166USING (iteration);
167
168-- Returns the Speedometer 3 score for all iterations in the trace
169CREATE PERFETTO FUNCTION chrome_speedometer_3_score()
170-- Speedometer 3 score
171RETURNS DOUBLE
172AS
173SELECT AVG(score) FROM chrome_speedometer_3_iteration;
174
175-- Returns the utid for the main thread that ran Speedometer 3
176CREATE PERFETTO FUNCTION chrome_speedometer_3_renderer_main_utid()
177-- Renderer main utid
178RETURNS LONG
179AS
180WITH
181  start_event AS (
182    SELECT name || '-start' AS name FROM _chrome_speedometer_3_measure_name
183  )
184SELECT utid
185FROM thread_track
186WHERE
187  id IN (
188    SELECT track_id
189    FROM slice, start_event
190    USING (name)
191    WHERE category = 'blink.user_timing'
192  )
193