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-- The values are being filled by Trace Processor when parsing the trace. 17-- Exposed with `trace_bounds`. 18CREATE TABLE _trace_bounds AS 19SELECT 20 0 AS start_ts, 21 0 AS end_ts; 22 23-- Fetch start of the trace. 24CREATE PERFETTO FUNCTION trace_start() 25-- Start of the trace. 26RETURNS TIMESTAMP AS 27SELECT 28 start_ts 29FROM _trace_bounds; 30 31-- Fetch end of the trace. 32CREATE PERFETTO FUNCTION trace_end() 33-- End of the trace. 34RETURNS TIMESTAMP AS 35SELECT 36 end_ts 37FROM _trace_bounds; 38 39-- Fetch duration of the trace. 40CREATE PERFETTO FUNCTION trace_dur() 41-- Duration of the trace. 42RETURNS DURATION AS 43SELECT 44 trace_end() - trace_start(); 45