1// Copyright (C) 2023 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import {DatasetSliceTrack} from '../../components/tracks/dataset_slice_track'; 16import {JANK_COLOR} from './jank_colors'; 17import {EventLatencySliceDetailsPanel} from './event_latency_details_panel'; 18import {Trace} from '../../public/trace'; 19import {SourceDataset} from '../../trace_processor/dataset'; 20import {LONG, NUM, STR} from '../../trace_processor/query_result'; 21import {getColorForSlice} from '../../components/colorizer'; 22 23export const JANKY_LATENCY_NAME = 'Janky EventLatency'; 24 25export function createEventLatencyTrack( 26 trace: Trace, 27 uri: string, 28 baseTable: string, 29) { 30 return new DatasetSliceTrack({ 31 trace, 32 uri, 33 dataset: new SourceDataset({ 34 schema: { 35 id: NUM, 36 ts: LONG, 37 dur: LONG, 38 name: STR, 39 depth: NUM, 40 }, 41 src: baseTable, 42 }), 43 colorizer: (row) => { 44 return row.name === JANKY_LATENCY_NAME 45 ? JANK_COLOR 46 : getColorForSlice(row.name); 47 }, 48 detailsPanel: (row) => new EventLatencySliceDetailsPanel(trace, row.id), 49 }); 50} 51