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 16DROP VIEW IF EXISTS {{table_name_prefix}}_relevant_slices_in_cuj; 17CREATE VIEW {{table_name_prefix}}_relevant_slices_in_cuj AS 18SELECT slice.ts, slice.dur FROM {{relevant_slices_table}} slice 19JOIN android_sysui_cuj_ts_boundaries boundaries 20ON slice.ts + slice.dur >= boundaries.ts AND slice.ts <= boundaries.ts_end; 21 22DROP TABLE IF EXISTS {{table_name_prefix}}_cuj_join_table; 23CREATE VIRTUAL TABLE {{table_name_prefix}}_cuj_join_table 24USING span_join( 25 android_sysui_cuj_ts_boundaries, 26 {{table_name_prefix}}_relevant_slices_in_cuj); 27 28DROP TABLE IF EXISTS {{table_name_prefix}}_frame_join_table; 29CREATE VIRTUAL TABLE {{table_name_prefix}}_frame_join_table 30USING span_join( 31 android_sysui_cuj_missed_frames_hwui_times partitioned frame_number, 32 {{table_name_prefix}}_relevant_slices_in_cuj); 33 34DROP VIEW IF EXISTS {{table_name_prefix}}_per_cuj_output_data; 35CREATE VIEW {{table_name_prefix}}_per_cuj_output_data AS 36SELECT SUM(dur) as dur_sum, MAX(dur) as dur_max 37FROM {{table_name_prefix}}_cuj_join_table; 38 39DROP VIEW IF EXISTS {{table_name_prefix}}_per_frame_output_data; 40CREATE VIEW {{table_name_prefix}}_per_frame_output_data AS 41SELECT 42f.frame_number, 43f.vsync, 44f.dur_frame, 45f.app_missed, 46SUM(jt.dur) as dur_sum, 47MAX(jt.dur) as dur_max 48FROM android_sysui_cuj_missed_frames f 49JOIN {{table_name_prefix}}_frame_join_table jt USING (frame_number) 50GROUP BY f.frame_number, f.vsync, f.dur_frame, f.app_missed; 51