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 {info} from "../../../log/Log.js"; 17 18export const initMemoryStrategy = (metricData: Array<any>): ProcessMetricsListItems => { 19 info("Memory Strategy data length is:", metricData.length) 20 let processMetricsListItems: Array<ProcessMetricsItems> = [] 21 for (let sqlIndex = 0; sqlIndex < metricData.length; sqlIndex++) { 22 let processName = metricData[sqlIndex].processName; 23 let minNum = metricData[sqlIndex].minNum < 0 ? 0 : metricData[sqlIndex].minNum; 24 let maxNum = metricData[sqlIndex].maxNum; 25 let avgNum = metricData[sqlIndex].avgNum; 26 let processInfoSource: ProcessMetricsItems = { 27 processName: processName, 28 overallCounters: { 29 anonRss: { 30 min: minNum, 31 max: maxNum, 32 avg: avgNum, 33 } 34 } 35 } 36 processMetricsListItems?.push(processInfoSource); 37 } 38 return { 39 processMetrics: processMetricsListItems 40 } 41} 42 43export interface ProcessMetricsListItems { 44 processMetrics: Array<ProcessMetricsItems> 45} 46 47export interface ProcessMetricsItems { 48 processName: string 49 overallCounters: AnonRssItem 50} 51 52export interface AnonRssItem { 53 anonRss: TypeItem 54} 55 56export interface TypeItem { 57 min: number 58 max: number 59 avg: number 60} 61