1// Copyright (C) 2024 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 {Time} from '../../base/time'; 16import {DatasetSliceTrack} from '../../components/tracks/dataset_slice_track'; 17import {Trace} from '../../public/trace'; 18import {SourceDataset} from '../../trace_processor/dataset'; 19import {LONG, NUM, STR} from '../../trace_processor/query_result'; 20import { 21 HeapProfileFlamegraphDetailsPanel, 22 profileType, 23} from './heap_profile_details_panel'; 24 25export function createHeapProfileTrack( 26 trace: Trace, 27 uri: string, 28 tableName: string, 29 upid: number, 30 heapProfileIsIncomplete: boolean, 31) { 32 return new DatasetSliceTrack({ 33 trace, 34 uri, 35 dataset: new SourceDataset({ 36 src: tableName, 37 schema: { 38 ts: LONG, 39 type: STR, 40 id: NUM, 41 }, 42 }), 43 detailsPanel: (row) => { 44 const ts = Time.fromRaw(row.ts); 45 const type = profileType(row.type); 46 return new HeapProfileFlamegraphDetailsPanel( 47 trace, 48 heapProfileIsIncomplete, 49 upid, 50 type, 51 ts, 52 ); 53 }, 54 tooltip: (row) => { 55 return [row.type]; 56 }, 57 }); 58} 59