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 initSysCallsStrategy = (metricData: Array<any>): FunctionListItem => { 19 info("System Calls Strategy data length is:", metricData.length) 20 let functionListItems: Array<FunctionItem> = [] 21 for (let sqlIndex = 0; sqlIndex < metricData.length; sqlIndex++) { 22 let functionNames = metricData[sqlIndex].funName; 23 let durMaxes = metricData[sqlIndex].maxDur; 24 let durMines = metricData[sqlIndex].minDur; 25 let durAvgs = Math.floor(metricData[sqlIndex].avgDur).toString(); 26 let functionItem: FunctionItem = { 27 functionName: functionNames, 28 durMax: durMaxes, 29 durMin: durMines, 30 durAvg: durAvgs, 31 } 32 functionListItems?.push(functionItem) 33 } 34 return { 35 function: functionListItems 36 } 37} 38 39export interface FunctionListItem { 40 function: Array<FunctionItem> 41} 42 43export interface FunctionItem { 44 functionName: string 45 durMax: string 46 durMin: string 47 durAvg: string 48} 49