1// Copyright (c) 2021 Huawei Device Co., Ltd. 2// Licensed under the Apache License, Version 2.0 (the "License"); 3// you may not use this file except in compliance with the License. 4// You may obtain a copy of the License at 5// 6// http://www.apache.org/licenses/LICENSE-2.0 7// 8// Unless required by applicable law or agreed to in writing, software 9// distributed under the License is distributed on an "AS IS" BASIS, 10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11// See the License for the specific language governing permissions and 12// limitations under the License. 13 14export const CHART_OFFSET_LEFT = 248; 15export enum QueryEnum { 16 ClearMemoryCache = -1, 17 CpuData = 0, 18 CpuStateData = 1, 19 CpuFreqData = 2, 20 CpuFreqLimitData = 3, 21 ClockData = 4, 22 IrqData = 5, 23 ProcessData = 6, 24 ProcessMemData = 7, 25 ProcessStartupData = 8, 26 ProcessSoInitData = 9, 27 HiSysEventData = 10, 28 HilogData = 11, 29 VirtualMemoryData = 12, 30 EnergySystemData = 13, 31 EnergyStateData = 14, 32 EnergyAnomalyData = 15, 33 FrameExpectedData = 16, 34 FrameActualData = 17, 35 FrameAnimationData = 18, 36 FrameDynamicData = 19, 37 FrameSpacingData = 20, 38 EnergyPowerData = 47, 39 FileSystemData = 48, 40 DiskIoData = 49, 41 EBPFVm = 50, 42 VmTrackerSmapsData = 81, 43 VmTrackerDmaData = 82, 44 VmTrackerGpuMemoryData = 83, 45 VmTrackerGpuData = 84, 46 VmTrackerGpuResourceData = 85, 47 VmTrackerGpuTotalData = 86, 48 VmTrackerGpuWindowData = 87, 49 VmTrackerShmData = 88, 50 VmTrackerPurgeableData = 89, 51 AbilityMemoryUsedData = 90, 52 CpuAbilityUserData = 91, 53 CpuAbilitySystemData = 92, 54 CpuAbilityMonitorData = 93, 55 AbilityBytesReadData = 94, 56 AbilityBytesWrittenData = 95, 57 AbilityReadOpsData = 96, 58 AbilityWrittenOpsData = 97, 59 AbilityBytesInTraceData = 98, 60 AbilityBytesOutTraceData = 99, 61 AbilityPacketInTraceData = 100, 62 AbilityPacketsOutTraceData = 101, 63 AbilityCachedFilesData, 64 AbilityCompressedData, 65 AbilityPurgeableData = 151, 66 AbilityGpuMemoryData = 152, 67 AbilityDmaData = 153, 68 ThreadData = 30, 69 FuncData = 31, 70 HiperfCpuData = 200, 71 HiperfProcessData = 201, 72 HiperfThreadData = 202, 73 HiperfCallChart = 203, 74 HiperfCallStack = 204, 75 NativeMemoryChartData = 205, 76 NativeMemoryChartCacheNormal = 206, 77 NativeMemoryChartCacheStatistic = 207, 78 processExpectedData = 26, 79 processActualData = 27, 80 processDeliverInputEventData = 28, 81 HeapTimelineData = 160, 82 HeapSnapshotData = 161, 83 CpuProfilerData = 162, 84 SearchCpuData = 163, 85 LostFrameData = 164, 86 HitchTime = 165, 87 SliceData = 300, 88 SliceSPTData = 301, 89} 90export const MAX_COUNT = 2000; 91export enum TraficEnum { 92 Memory, 93 SharedArrayBuffer, 94 TransferArrayBuffer, 95 ProtoBuffer, 96} 97 98export function threadStateToNumber(state: string): number { 99 return threadStateArray.findIndex((it) => it === state); 100} 101export function threadStateToString(state: number): string { 102 if (state === -1) { 103 return ''; 104 } else { 105 return threadStateArray[state]; 106 } 107} 108const threadStateArray = ['D-NIO', 'DK-NIO', 'D-IO', 'DK-IO', 'D', 'DK', 'R', 'R+', 'R-B', 'I', 'Running', 'S']; 109