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