• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-- Definition of `trace_bounds` table. The values are being filled by Trace
17-- Processor when parsing the trace. Can't be a Perfetto table because it has
18-- to be mutable.
19-- It is recommended to depend on the `trace_start()` and `trace_end()`
20-- functions rather than directly on `trace_bounds`.
21CREATE TABLE trace_bounds AS
22SELECT 0 AS start_ts, 0 AS end_ts;
23
24-- Fetch start of the trace.
25CREATE PERFETTO FUNCTION trace_start()
26-- Start of the trace in nanoseconds.
27RETURNS LONG AS
28SELECT start_ts FROM trace_bounds;
29
30-- Fetch end of the trace.
31CREATE PERFETTO FUNCTION trace_end()
32-- End of the trace in nanoseconds.
33RETURNS LONG AS
34SELECT end_ts FROM trace_bounds;
35
36-- Fetch duration of the trace.
37CREATE PERFETTO FUNCTION trace_dur()
38-- Duration of the trace in nanoseconds.
39RETURNS LONG AS
40SELECT trace_end() - trace_start();