1-- 2-- Copyright 2021 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::{gesture_update} 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 {{prefix}}_flow_event table which gives us all the flow events 22-- with associated {gesture_update} events we care about and labels them 23-- janky or not. 24SELECT RUN_METRIC('chrome/{{prefix}}_flow_event.sql'); 25 26-- Take each flow and next flow (from {{prefix}}_flow_event table) and generate 27-- the metric name as well as compute the time between. 28DROP VIEW IF EXISTS {{prefix}}_flow_event_queuing_delay; 29 30CREATE VIEW {{prefix}}_flow_event_queuing_delay AS 31SELECT 32 trace_id, 33 id, 34 ts, 35 dur, 36 track_id, 37 {{id_field}}, 38 avg_vsync_interval, 39 {{prefix}}_slice_id, 40 {{prefix}}_ts, 41 {{prefix}}_dur, 42 {{prefix}}_track_id, 43 jank, 44 step, 45 ancestor_id, 46 ancestor_ts, 47 ancestor_end, 48 next_id, 49 next_step, 50 maybe_next_ancestor_ts, 51 next_track_id, 52 CASE WHEN trace_id = next_trace_id THEN 53 'InputLatency.LatencyInfo.Flow.QueuingDelay.' 54 || CASE WHEN 55 jank IS NOT NULL 56 AND jank = 1 57 THEN 58 'Jank.' 59 ELSE 60 'NoJank.' 61 END 62 || step || '-to-' || next_step 63 ELSE 64 step 65 END AS description, 66 CASE WHEN maybe_next_ancestor_ts IS NULL THEN 67 NULL 68 ELSE 69 CASE WHEN maybe_next_ancestor_ts > ancestor_end THEN 70 (maybe_next_ancestor_ts - ancestor_end) 71 ELSE 72 0 73 END 74 END AS queuing_time_ns 75FROM {{prefix}}_flow_event 76ORDER BY {{id_field}}, trace_id, ts; 77