blob: bf8c628104c5697919c177c15e70a5dc87b5380a [file] [log] [blame]
Rasika Navarange0e3d9b62023-08-23 11:45:031-- 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
5DROP TABLE IF EXISTS chrome_vsync_intervals;
6
7-- A simple table that checks the time between VSync (this can be used to
8-- determine if we're refreshing at 90 FPS or 60 FPS).
9--
10-- Note: In traces without the "Java" category there will be no VSync
11-- TraceEvents and this table will be empty.
12CREATE PERFETTO TABLE chrome_vsync_intervals AS
13SELECT
14 slice_id,
15 ts,
16 dur,
17 track_id,
18 LEAD(ts) OVER(PARTITION BY track_id ORDER BY ts) - ts AS time_to_next_vsync
19FROM slice
20WHERE name = "VSync"
21ORDER BY track_id, ts;
22
23-- Function: compute the average Vysnc interval of the
24-- gesture (hopefully this would be either 60 FPS for the whole gesture or 90
25-- FPS but that isn't always the case) on the given time segment.
26-- If the trace doesn't contain the VSync TraceEvent we just fall back on
27-- assuming its 60 FPS (this is the 1.6e+7 in the COALESCE which
28-- corresponds to 16 ms or 60 FPS).
29--
30-- begin_ts: segment start time
31-- end_ts: segment end time
32CREATE PERFETTO FUNCTION calculate_avg_vsync_interval(
33 begin_ts LONG,
34 end_ts LONG
35)
36-- Returns: the average Vysnc interval on this time segment
37-- or 1.6e+7, if trace doesnt contain the VSync TraceEvent.
38RETURNS FLOAT AS
39SELECT
40 COALESCE((
41 SELECT
42 CAST(AVG(time_to_next_vsync) AS FLOAT)
43 FROM chrome_vsync_intervals in_query
44 WHERE
45 time_to_next_vsync IS NOT NULL AND
46 in_query.ts > $begin_ts AND
47 in_query.ts < $end_ts
48 ), 1e+9 / 60);