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(); 63//xpowerStastic 泳道 memory 模式缓存 64export const xpowerStasticList: Map<string, Array<unknown>> = new Map(); 65//xpowerWifiList 泳道 memory 模式缓存 66export const xpowerWifiList: Map<string, Array<unknown>> = new Map(); 67//xpowerAppDetailList 泳道 memory 模式缓存 68export const xpowerAppDetailList: Map<string, Array<unknown>> = new Map(); 69export function clearMemoryCache(data: unknown, proc: Function): void { 70 sliceList.clear(); 71 cpuList.clear(); 72 clockList.clear(); 73 cpuFreqList.clear(); 74 cpuFreqLimitList.clear(); 75 cpuStateList.clear(); 76 threadCallStackList.clear(); 77 lrqList.clear(); 78 processList.clear(); 79 memList.clear(); 80 threadStateList.clear(); 81 processFrameList.clear(); 82 lostFrameList.clear(); 83 hitchTimeList.clear(); 84 hiSysEventList.clear(); 85 hiLogList.clear(); 86 energyList.clear(); 87 xpowerList.clear(); 88 xpowerStasticList.clear(); 89 xpowerWifiList.clear(); 90 xpowerAppDetailList.clear(); 91 hiPerfCallChartClearCache(true); 92 nativeMemoryCacheClear(); 93 resetVmTracker(); 94 resetAbilityMonitor(); 95 resetAbility(); 96 resetVM(); 97 resetDynamicEffect(); 98 resetEnergyEvent(); 99 (self as unknown as Worker).postMessage( 100 { 101 //@ts-ignore 102 id: data.id, //@ts-ignore 103 action: data.action, 104 results: 'ok', 105 len: 0, 106 transfer: [], 107 }, 108 [] 109 ); 110} 111