1-- 2-- Copyright 2023 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 16INCLUDE PERFETTO MODULE android.slices; 17 18SELECT RUN_METRIC('android/sysui_notif_shade_list_builder_slices.sql'); 19 20-- Get statics of all ShadeListBuilder.buildList slices 21DROP TABLE IF EXISTS shade_list_builder_all; 22CREATE PERFETTO TABLE shade_list_builder_all AS 23SELECT 24 s.name name, 25 COUNT(s.name) AS count, 26 cast(avg(dur) as int) average_dur_ns, 27 max(dur) maximum_dur_ns, 28 s.id id 29FROM shade_list_builder_build_list_slices s 30GROUP BY s.name; 31 32-- Id of shade_list_builder slices that has a descendant of inflation 33DROP VIEW IF EXISTS slices_id_with_inflation_descendants; 34CREATE PERFETTO VIEW slices_id_with_inflation_descendants AS 35SELECT DISTINCT id 36 FROM slices_and_descendants 37 WHERE 38 descendant_name = 'HybridGroupManager#inflateHybridView' OR 39 descendant_name = 'NotifChildCont#recreateHeader'; 40 41-- Id of shade_list_builder slices that has a descendant of ShadeNode modification 42DROP VIEW IF EXISTS slices_id_with_modification_descendants; 43CREATE PERFETTO VIEW slices_id_with_modification_descendants AS 44SELECT DISTINCT id 45 FROM slices_and_descendants 46 WHERE 47 descendant_name = 'ShadeNode#addChildAt' OR 48 descendant_name = 'ShadeNode#removeChildAt' OR 49 descendant_name = 'ShadeNode#moveChildTo'; 50 51DROP TABLE IF EXISTS shade_list_builder_slices_with_inflation; 52CREATE PERFETTO TABLE shade_list_builder_slices_with_inflation AS 53SELECT 54 s.name || "_with_inflation" name, 55 COUNT(s.name) AS count, 56 cast(avg(dur) as int) average_dur_ns, 57 max(dur) maximum_dur_ns 58FROM shade_list_builder_build_list_slices s 59WHERE s.id IN slices_id_with_inflation_descendants 60GROUP BY s.name; 61 62DROP TABLE IF EXISTS shade_list_builder_slices_with_modification; 63CREATE PERFETTO TABLE shade_list_builder_slices_with_modification AS 64SELECT 65 s.name || "_with_node_modification" name, 66 COUNT(s.name) AS count, 67 cast(avg(dur) as int) average_dur_ns, 68 max(dur) maximum_dur_ns 69FROM shade_list_builder_build_list_slices s 70WHERE s.id IN slices_id_with_modification_descendants 71GROUP BY s.name; 72 73 74DROP VIEW IF EXISTS sysui_notif_shade_list_builder_metric_output; 75CREATE PERFETTO VIEW sysui_notif_shade_list_builder_metric_output AS 76SELECT SysuiNotifShadeListBuilderMetric( 77 'all_slices_performance', ( 78 SELECT SysUiSlicePerformanceStatisticalData( 79 'name', a.name, 80 'cnt', a.count, 81 'avg_dur_ms', cast (a.average_dur_ns / 1000000 as int), 82 'max_dur_ms', cast (a.maximum_dur_ns / 1000000 as int), 83 'avg_dur_ns', a.average_dur_ns, 84 'max_dur_ns', a.maximum_dur_ns 85 ) 86 FROM shade_list_builder_all a 87 ), 88 'slices_with_inflation_performance', ( 89 SELECT SysUiSlicePerformanceStatisticalData( 90 'name', a.name, 91 'cnt', a.count, 92 'avg_dur_ms', cast (a.average_dur_ns / 1000000 as int), 93 'max_dur_ms', cast (a.maximum_dur_ns / 1000000 as int), 94 'avg_dur_ns', a.average_dur_ns, 95 'max_dur_ns', a.maximum_dur_ns 96 ) 97 FROM shade_list_builder_slices_with_inflation a 98 ), 99 'slices_with_modification_performance', ( 100 SELECT SysUiSlicePerformanceStatisticalData( 101 'name', a.name, 102 'cnt', a.count, 103 'avg_dur_ms', cast (a.average_dur_ns / 1000000 as int), 104 'max_dur_ms', cast (a.maximum_dur_ns / 1000000 as int), 105 'avg_dur_ns', a.average_dur_ns, 106 'max_dur_ns', a.maximum_dur_ns 107 ) 108 FROM shade_list_builder_slices_with_modification a 109 ), 110 'slice', ( 111 SELECT RepeatedField( 112 SysuiNotifShadeListBuilderMetric_SliceDuration( 113 'name', a.name, 114 'dur_ms', cast (a.dur / 1000000 as int), 115 'dur_ns', a.dur 116 ) 117 ) 118 FROM shade_list_builder_build_list_slices a 119 ORDER BY dur DESC 120 ) 121);