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 {Utils} from "../component/trace/base/Utils.js"; 17import {ChartStruct} from "../bean/FrameChartStruct.js"; 18 19export class NativeHookStatistics { 20 eventId: number = 0; 21 eventType: string = ""; 22 subType: string = ""; 23 subTypeId: number = 0; 24 heapSize: number = 0; 25 addr: string = ""; 26 startTs: number = 0; 27 endTs: number = 0; 28 sumHeapSize: number = 0; 29 max: number = 0; 30 count: number = 0; 31 tid: number = 0; 32 threadName: string = ""; 33 isSelected: boolean = false; 34} 35 36export class NativeHookMalloc { 37 eventType: string = ""; 38 subType: string = ""; 39 subTypeId: number = 0; 40 heapSize: number = 0; 41 allocByte: number = 0; 42 allocCount: number = 0; 43 freeByte: number = 0; 44 freeCount: number = 0; 45 max: number = 0; 46} 47 48export class NativeEventHeap { 49 eventType: string = ""; 50 sumHeapSize: number = 0 51} 52 53export class NativeHookProcess { 54 ipid: number = 0; 55 pid: number = 0; 56 name: String = "" 57} 58 59export class NativeHookStatisticsTableData { 60 memoryTap: string = ""; 61 existing: number = 0; 62 existingString: string = ""; 63 freeByteString: string = ""; 64 allocCount: number = 0; 65 freeCount: number = 0; 66 freeByte: number = 0; 67 totalBytes: number = 0 68 totalBytesString: string = ""; 69 maxStr: string = ""; 70 max: number = 0 71 totalCount: number = 0; 72 existingValue: Array<number> = []; 73} 74 75export class NativeMemory { 76 index: number = 0; 77 eventId: number = 0; 78 eventType: string = ""; 79 subType: string = ""; 80 addr: string = ""; 81 startTs: number = 0; 82 endTs: number = 0; 83 timestamp: string = "" 84 heapSize: number = 0; 85 heapSizeUnit: string = ""; 86 symbol: string = ""; 87 library: string = ""; 88 isSelected: boolean = false; 89 state:string = ""; 90 threadId:number = 0; 91 threadName:string = ""; 92} 93 94export class NativeHookSamplerInfo { 95 current: string = "" 96 currentSize: number = 0 97 startTs: number = 0; 98 heapSize: number = 0; 99 snapshot: string = ""; 100 growth: string = ""; 101 total: number = 0; 102 totalGrowth: string = "" 103 existing: number = 0; 104 children: Array<NativeHookSamplerInfo> = []; 105 tempList: Array<NativeHookSamplerInfo> = []; 106 timestamp: string = "" 107 eventId: number = -1 108 threadId:number = 0; 109 threadName:string = ""; 110 111 merageObj(merageObj: NativeHookSamplerInfo) { 112 this.currentSize += merageObj.currentSize 113 this.heapSize += merageObj.heapSize 114 this.existing += merageObj.existing 115 this.total += merageObj.total 116 this.growth = Utils.getByteWithUnit(this.heapSize) 117 this.current = Utils.getByteWithUnit(this.currentSize) 118 this.totalGrowth = Utils.getByteWithUnit(this.total) 119 } 120} 121 122export class NativeHookSampleQueryInfo { 123 eventId: number = -1 124 current: number = 0 125 eventType: string = ""; 126 subType: string = ""; 127 subTypeId: number = 0; 128 growth: number = 0; 129 existing: number = 0; 130 addr: string = ""; 131 startTs: number = 0; 132 endTs: number = 0; 133 total: number = 0; 134 threadId:number = 0; 135 threadName:string = ""; 136 children: Array<NativeHookSamplerInfo> = []; 137} 138 139export class NativeHookCallInfo extends ChartStruct { 140 id: string = ""; 141 pid: string | undefined; 142 library: string = ""; 143 symbolId:number = 0; 144 title: string = ""; 145 count: number = 0; 146 countValue:string = "" 147 countPercent: string = ""; 148 type: number = 0; 149 heapSize: number = 0; 150 heapPercent: string = ""; 151 heapSizeStr: string = ""; 152 eventId: number = 0; 153 threadId: number = 0; 154 threadName: string = ""; 155 isSelected: boolean = false; 156} 157 158export class NativeEvent { 159 startTime:number = 0; 160 heapSize:number = 0; 161 eventType:string = ""; 162}