• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 initSysCallsTopStrategy = (metricData: Array<any>): ProcessInfoListItem => {
19    info("System Calls Strategy data length is:", metricData.length)
20    let ProcessInfoListItems: Array<ProcessInfoItem> = []
21
22    for (let sqlIndex = 0; sqlIndex < metricData.length; sqlIndex++) {
23        let pidList = metricData[sqlIndex].pid;
24        let tidList = metricData[sqlIndex].tid;
25        let functionNames = metricData[sqlIndex].funName;
26        let durMaxes = metricData[sqlIndex].maxDur;
27        let durMines = metricData[sqlIndex].minDur < 0 ? 0 : metricData[sqlIndex].minDur;
28        let durAvgs = Math.floor(metricData[sqlIndex].avgDur).toString();
29
30        let processInfoItem: ProcessInfoItem = {
31            pid: pidList,
32            threads: {
33                tid: tidList,
34                function: {
35                    functionName: functionNames,
36                    durMax: durMaxes,
37                    durMin: durMines,
38                    durAvg: durAvgs,
39                },
40            },
41        }
42        ProcessInfoListItems?.push(processInfoItem)
43    }
44    return {
45        processInfo: ProcessInfoListItems
46    }
47}
48
49export interface ProcessInfoListItem {
50    processInfo: Array<ProcessInfoItem>
51}
52
53export interface ProcessInfoItem {
54    pid: string
55    threads: ThreadsItem
56}
57
58
59export interface ThreadsItem {
60    tid: string
61    function: FunctionItem
62}
63
64export interface FunctionItem {
65    functionName: string
66    durMax: string
67    durMin: string
68    durAvg: string
69}
70