# Copyright (C) 2025 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # We compute the duration of the current value by subtracting the current timestamp # from the timestamp of the next value. # The LEAD function is used to get the next timestamp. If there is no next timestamp, it uses the # end of the trace as the next timestamp. metric_template_spec: { id_prefix: "android_dmabuf_per_process_metric" dimensions: "process_name" value_columns: "min_val" value_columns: "max_val" value_columns: "avg_val" query: { sql: { column_names: "process_name" column_names: "metric_val" column_names: "dur" sql: " INCLUDE PERFETTO MODULE android.memory.dmabuf; SELECT process_name, value AS metric_val, LEAD(ts, 1, (SELECT end_ts FROM trace_bounds)) OVER(PARTITION BY COALESCE(upid, utid) ORDER BY ts) - ts AS dur FROM android_memory_cumulative_dmabuf WHERE upid IS NOT NULL " } filters: { column_name: "process_name" op: EQUAL string_rhs: "com.android.systemui" string_rhs: "com.google.android.apps.nexuslauncher" string_rhs: "system_server" } group_by: { column_names: "process_name" aggregates: { column_name: "metric_val" op: MIN result_column_name: "min_val" } aggregates: { column_name: "metric_val" op: MAX result_column_name: "max_val" } aggregates: { column_name: "metric_val" op: DURATION_WEIGHTED_MEAN result_column_name: "avg_val" } } } }