1-- 2-- Copyright 2022 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-- This metric calculates the number of user inputs during a scroll per frame 18-- generated, this can be used to track smoothness. 19-- For normal input, we expect 2 inputs per frame, for flings, we expect 20-- 1 input per frame as flings are generated once per vsync. 21-- The numbers mentioned above are estimates in the ideal case scenario. 22 23-- Grab all GestureScrollUpdate slices. 24DROP VIEW IF EXISTS chrome_all_scroll_updates; 25CREATE VIEW chrome_all_scroll_updates AS 26SELECT 27 id, 28 EXTRACT_ARG(arg_set_id, 'chrome_latency_info.gesture_scroll_id') AS scroll_id, 29 EXTRACT_ARG(arg_set_id, 'chrome_latency_info.is_coalesced') AS is_coalesced, 30 ts, 31 dur, 32 track_id 33FROM slice 34WHERE name = "InputLatency::GestureScrollUpdate"; 35 36-- Count number of input GestureScrollUpdates per scroll. 37DROP VIEW IF EXISTS chrome_update_count_per_scroll; 38CREATE VIEW chrome_update_count_per_scroll AS 39SELECT 40 CAST(COUNT() AS FLOAT) AS count, 41 scroll_id, 42 dur, 43 track_id 44FROM chrome_all_scroll_updates 45GROUP BY scroll_id; 46 47-- Count the number of input GestureScrollUpdates that were converted 48-- frames per scroll. 49DROP VIEW IF EXISTS chrome_non_coalesced_update_count_per_scroll; 50CREATE VIEW chrome_non_coalesced_update_count_per_scroll AS 51SELECT 52 CAST(COUNT() AS FLOAT) AS non_coalesced_count, 53 scroll_id, 54 id, 55 track_id, 56 dur 57FROM chrome_all_scroll_updates 58WHERE NOT is_coalesced 59GROUP BY scroll_id; 60 61-- Get the average number of inputs per frame per scroll. 62DROP VIEW IF EXISTS chrome_avg_scroll_inputs_per_frame; 63CREATE VIEW chrome_avg_scroll_inputs_per_frame AS 64SELECT 65 count / non_coalesced_count AS avg_inputs_per_frame_per_scroll, 66 scroll_id, 67 non_coalesced_count 68FROM chrome_non_coalesced_update_count_per_scroll 69JOIN chrome_update_count_per_scroll USING(scroll_id); 70 71-- Get the last scroll update event that wasn't coalesced before the 72-- current scroll update. 73DROP VIEW IF EXISTS chrome_frame_main_input_id; 74CREATE VIEW chrome_frame_main_input_id AS 75SELECT 76 id, 77 scroll_id, 78 is_coalesced, 79 ts, 80 dur, 81 track_id, 82 (SELECT 83 MAX(id) 84 FROM chrome_all_scroll_updates parent_scrolls 85 WHERE NOT is_coalesced 86 AND parent_scrolls.ts <= scrolls.ts) AS presented_scroll_id 87FROM chrome_all_scroll_updates scrolls; 88 89-- Count the number of inputs per presented frame. 90DROP VIEW IF EXISTS chrome_scroll_inputs_per_frame; 91CREATE VIEW chrome_scroll_inputs_per_frame AS 92SELECT 93 COUNT() AS count_for_frame, 94 presented_scroll_id, 95 ts, 96 dur, 97 id AS slice_id, 98 track_id 99FROM 100 chrome_frame_main_input_id 101GROUP BY presented_scroll_id; 102