1-- 2-- Copyright 2020 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-- This metric takes each flow event in a InputLatency::GestureScrollUpdate and 17-- and computes the time from the ancestor_end of the current flow to the 18-- ancestor_ts of the next flow event. This is a reasonable approximation of the 19-- time we waited for the next step in the critical flow to start. 20 21-- Provides the scroll_flow_event table which gives us all the flow events with 22-- associated GestureScrollUpdate events we care about and labels them janky or 23-- not. 24SELECT RUN_METRIC('chrome/scroll_flow_event.sql'); 25 26-- Take each flow and next flow (from scroll_flow_event table) and generate the 27-- metric name as well as compute the time between. 28DROP VIEW IF EXISTS scroll_flow_event_queuing_delay; 29 30CREATE VIEW scroll_flow_event_queuing_delay AS 31 SELECT 32 trace_id, 33 id, 34 ts, 35 dur, 36 track_id, 37 gesture_scroll_id, 38 scroll_slice_id, 39 scroll_ts, 40 scroll_dur, 41 scroll_track_id, 42 jank, 43 step, 44 ancestor_id, 45 ancestor_ts, 46 ancestor_end, 47 next_id, 48 next_step, 49 maybe_next_ancestor_ts, 50 next_track_id, 51 CASE WHEN trace_id = next_trace_id THEN 52 'InputLatency.LatencyInfo.Flow.QueuingDelay.' || 53 CASE WHEN 54 jank IS NOT NULL AND 55 jank = 1 56 THEN 57 'Jank.' 58 ELSE 59 'NoJank.' 60 END 61 || step || '-to-' || next_step 62 ELSE 63 step 64 END AS description, 65 CASE WHEN maybe_next_ancestor_ts IS NULL THEN 66 NULL 67 ELSE 68 CASE WHEN maybe_next_ancestor_ts > ancestor_end THEN 69 (maybe_next_ancestor_ts - ancestor_end) 70 ELSE 71 0 72 END 73 END AS queuing_time_ns 74 FROM scroll_flow_event 75 ORDER BY gesture_scroll_id, trace_id, ts; 76