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. 13import { hiPerfCallChartClearCache } from '../hiperf/HiperfCallChartReceiver'; 14import { nativeMemoryCacheClear } from '../NativeMemoryDataReceiver'; 15import { resetVmTracker } from '../VmTrackerDataReceiver'; 16import { resetVM } from '../VirtualMemoryDataReceiver'; 17import { resetAbilityMonitor } from '../AbilityMonitorReceiver'; 18import { resetAbility } from '../VmTrackerDataReceiver'; 19import { resetDynamicEffect } from '../FrameDynamicEffectReceiver'; 20import { resetEnergyEvent } from '../EnergySysEventReceiver'; 21import { HangSQLStruct } from '../HangDataReceiver'; 22// thread_state 表缓存 23export const sliceList: Map<number, Array<unknown>> = new Map(); 24//cpu 泳道 memory 缓存 25export const cpuList: Map<number, Array<unknown>> = new Map(); 26//clock 泳道 memory 模式缓存 27export const clockList: Map<string, Array<unknown>> = new Map(); 28//hang 泳道 memory 模式缓存 29export const hangList: Map<string, Array<HangSQLStruct>> = new Map(); 30//cpu freq 泳道 memory模式缓存 31export const cpuFreqList: Map<number, Array<unknown>> = new Map(); 32//cpu freq limit 泳道 memory模式缓存 33export const cpuFreqLimitList: Map<number, Array<unknown>> = new Map(); 34//cpu state 泳道 memory模式缓存 35export const cpuStateList: Map<number, Array<unknown>> = new Map(); 36//thread call stack 泳道图 memory 模式缓存 37export const threadCallStackList: Map<string, Array<unknown>> = new Map(); 38//irq 泳道图 memory 模式缓存 39export const lrqList: Map<string, Array<unknown>> = new Map(); 40//Lost Frame 泳道图 memory 模式缓存 41export const lostFrameList: Map<number, Array<unknown>> = new Map(); 42//Hitch Time 泳道图 memory 模式缓存 43export const hitchTimeList: Map<number, Array<unknown>> = new Map(); 44//进程 泳道图 memory 模式缓存 45export const processList: Map<number, Array<unknown>> = new Map(); 46//进程内存 泳道图 memory 模式缓存数据 47export const memList: Map<number, Array<unknown>> = new Map(); 48//线程状态 泳道图 memory 模式缓存 49export const threadStateList: Map<string, Array<unknown>> = new Map(); 50//进程下卡顿丢帧 泳道图 memory 模式缓存 51export const processFrameList: Map<string, Array<unknown>> = new Map(); 52//hiSysEvent 泳道图 memory 模式缓存 53export const hiSysEventList: Map<string, Array<unknown>> = new Map(); 54//hiLog 泳道图 memory 模式缓存 55export const hiLogList: Map<string, Array<unknown>> = new Map(); 56 57//energy 泳道图 memory 模式缓存 58export const energyList: Map<string, Array<unknown>> = new Map(); 59//dma_fence 泳道图 memory 模式缓存 60export const dmaFenceList: Map<string, Array<unknown>> = new Map(); 61//xpower 泳道 memory 模式缓存 62export const xpowerList: Map<string, Array<unknown>> = new Map(); 63export function clearMemoryCache(data: unknown, proc: Function): void { 64 sliceList.clear(); 65 cpuList.clear(); 66 clockList.clear(); 67 cpuFreqList.clear(); 68 cpuFreqLimitList.clear(); 69 cpuStateList.clear(); 70 threadCallStackList.clear(); 71 lrqList.clear(); 72 processList.clear(); 73 memList.clear(); 74 threadStateList.clear(); 75 processFrameList.clear(); 76 lostFrameList.clear(); 77 hitchTimeList.clear(); 78 hiSysEventList.clear(); 79 hiLogList.clear(); 80 energyList.clear(); 81 xpowerList.clear(); 82 hiPerfCallChartClearCache(true); 83 nativeMemoryCacheClear(); 84 resetVmTracker(); 85 resetAbilityMonitor(); 86 resetAbility(); 87 resetVM(); 88 resetDynamicEffect(); 89 resetEnergyEvent(); 90 (self as unknown as Worker).postMessage( 91 { 92 //@ts-ignore 93 id: data.id, //@ts-ignore 94 action: data.action, 95 results: 'ok', 96 len: 0, 97 transfer: [], 98 }, 99 [] 100 ); 101} 102