• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 #include "executor/memory/get_process_info.h"
16 #include "executor/memory/memory_filter.h"
17 #include "executor/memory/memory_util.h"
18 using namespace std;
19 namespace OHOS {
20 namespace HiviewDFX {
GetProcessInfo()21 GetProcessInfo::GetProcessInfo()
22 {
23 }
~GetProcessInfo()24 GetProcessInfo::~GetProcessInfo()
25 {
26 }
27 
28 /**
29  * @description: get the value of process usage
30  * @param {GroupMap} &infos-Smaps information
31  * @return {uint64_t}-the value of
32  */
GetProcess(const GroupMap & infos) const33 uint64_t GetProcessInfo::GetProcess(const GroupMap &infos) const
34 {
35     uint64_t totalValue = 0;
36     for (const auto &info : infos) {
37         auto &valueMap = info.second;
38         for (const auto &str : MemoryFilter::GetInstance().CALC_PROCESS_TOTAL_) {
39             auto it = valueMap.find(str);
40             if (it != valueMap.end()) {
41                 totalValue += it->second;
42             }
43         }
44     }
45     return totalValue;
46 }
47 } // namespace HiviewDFX
48 } // namespace OHOS
49