1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 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 */ 15 16import { ChartStruct } from '../../trace/bean/FrameChartStruct.js'; 17 18export class PerfFile { 19 path: string = ''; 20 fileId: number = 0; 21 symbol: string = ''; 22 fileName: string = ''; 23 24 static setFileName(perfData: PerfFile) { 25 if (perfData.path) { 26 let number = perfData.path.lastIndexOf('/'); 27 if (number > 0) { 28 perfData.fileName = perfData.path.substring(number + 1); 29 return; 30 } 31 } 32 perfData.fileName = perfData.path; 33 } 34} 35 36export class PerfThread { 37 tid: number = 0; 38 pid: number = 0; 39 threadName: string = ''; 40 processName: string = ''; 41} 42 43export class PerfCall { 44 sampleId: number = 0; 45 depth: number = 0; 46 name: string = ''; 47} 48 49export class PerfCallChain { 50 tid: number = 0; 51 pid: number = 0; 52 parentId: string = ''; //合并之后区分的id 53 id: string = ''; 54 fileId: number = 0; 55 symbolId: number = 0; 56 topDownMerageId: string = ''; //top down合并使用的id 57 topDownMerageParentId: string = ''; //top down合并使用的id 58 bottomUpMerageId: string = ''; //bottom up合并使用的id 59 bottomUpMerageParentId: string = ''; //bottom up合并使用的id 60 sampleId: number = 0; 61 callChainId: number = 0; 62 name: string = ''; 63 fileName: string = ''; 64 threadState: string = ''; 65 startNS: number = 0; 66 dur: number = 0; 67 vaddrInFile: number = 0; 68 path: string = ''; 69 depth: number = 0; 70 canCharge: boolean = true; 71 previousNode: PerfCallChain | undefined = undefined; //将list转换为一个链表结构 72 nextNode: PerfCallChain | undefined = undefined; 73} 74 75export class PerfCallChainMerageData extends ChartStruct { 76 id: string = ''; 77 parentId: string = ''; 78 tid: number = 0; 79 pid: number = 0; 80 currentTreeParentNode: PerfCallChainMerageData | undefined = undefined; 81 symbolName: string = ''; 82 libName: string = ''; 83 symbol: string = ''; 84 path: string = ''; 85 self: string = '0s'; 86 weight: string = ''; 87 weightPercent: string = ''; 88 selfDur: number = 0; 89 dur: number = 0; 90 children: PerfCallChainMerageData[] = []; 91 initChildren: PerfCallChainMerageData[] = []; 92 isStore = 0; 93 isSelected: boolean = false; 94 canCharge: boolean = true; 95 type: number = 0; 96 vaddrInFile: number = 0; 97 searchShow: boolean = true; 98} 99 100export class PerfSample { 101 sampleId: number = 0; 102 time: number = 0; 103 timeString: string = ''; 104 core: number = 0; 105 coreName: string = ''; 106 state: string = ''; 107 pid: number = 0; 108 processName: string = ''; 109 tid: number = 0; 110 threadName: string = ''; 111 depth: number = 0; 112 addr: string = ''; 113 fileId: number = 0; 114 symbolId: number = 0; 115 backtrace: Array<string> = []; 116} 117 118export class PerfStack { 119 symbol: string = ''; 120 symbolId: number = 0; 121 path: string = ''; 122 fileId: number = 0; 123 type: number = 0; 124 vaddrInFile: number = 0; 125} 126 127export class PerfCmdLine { 128 report_value: string = ''; 129} 130