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-- 16 17CREATE OR REPLACE PERFETTO FUNCTION GET_LATENCY(tag STRING) 18RETURNS DOUBLE AS 19SELECT dur/1e6 FROM slices WHERE name = $tag ORDER BY dur DESC LIMIT 1; 20 21DROP VIEW IF EXISTS ad_services_metric_output; 22 23CREATE PERFETTO VIEW ad_services_metric_output 24AS 25SELECT 26 AdServicesMetric( 27 'ui_metric', 28 ( 29 SELECT 30 RepeatedField( 31 AdServicesUiMetric( 32 'main_activity_creation_latency', 33 (GET_LATENCY('AdServicesSettingsMainActivity#OnCreate')), 34 'consent_manager_read_latency', 35 (GET_LATENCY('ConsentManager#ReadOperation')), 36 'consent_manager_write_latency', 37 (GET_LATENCY('ConsentManager#WriteOperation')), 38 'consent_manager_initialization_latency', 39 (GET_LATENCY('ConsentManager#Initialization')))) 40 ), 41 'app_set_id_metric', 42 ( 43 SELECT 44 RepeatedField( 45 AdServicesAppSetIdMetric( 46 'latency', GET_LATENCY('AdIdCacheEvent'))) 47 ), 48 'ad_id_metric', 49 ( 50 SELECT 51 RepeatedField( 52 AdServicesAdIdMetric('latency', GET_LATENCY('AppSetIdEvent'))) 53 ), 54 'odp_metric', 55 ( 56 SELECT 57 RepeatedField( 58 OnDevicePersonalizationMetric( 59 'managing_service_initialization_latency', 60 (GET_LATENCY('OdpManagingService#Initialization')), 61 'service_delegate_execute_flow_latency', 62 (GET_LATENCY('OdpManagingServiceDelegate#Execute')), 63 'service_delegate_request_surface_package_latency', 64 (GET_LATENCY('OdpManagingServiceDelegate#RequestSurfacePackage')), 65 'service_delegate_register_web_trigger_latency', 66 (GET_LATENCY('OdpManagingServiceDelegate#RegisterWebTrigger')))) 67 )); 68