1 /*
2  * Copyright (C) 2021 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 #ifndef RAM_H
16 #define RAM_H
17 #include "sp_profiler.h"
18 #include <string>
19 
20 enum {
21     RAM_ONE = 1,
22     RAM_SECOND,
23     RAM_THIRD,
24     RAM_FOURTH,
25     RAM_FIFTH,
26     RAM_SIXTH,
27     RAM_SEVENTH,
28     RAM_EIGHTH,
29     RAM_NINTH,
30     RAM_TENTH,
31 };
32 
33 namespace OHOS {
34 namespace SmartPerf {
35 class RAM : public SpProfiler {
36 public:
37     std::map<std::string, std::string> GetSysRamInfo() const;
38     std::map<std::string, std::string> GetRamInfo() const;
39     std::map<std::string, std::string> GetPssRamInfo(FILE *fd, std::vector<std::string> paramsInfo) const;
40     std::map<std::string, std::string> ParsePssValues(FILE *fd, std::vector<std::string> &paramsInfo) const;
41     std::map<std::string, std::string> SaveSumRamInfo(std::vector<std::string> paramsInfo) const;
42     std::map<std::string, std::string> ProcMemNaInfo() const;
GetInstance()43     static RAM &GetInstance()
44     {
45         static RAM instance;
46         return instance;
47     }
48     std::map<std::string, std::string> ItemData() override;
49     void SetPackageName(const std::string &pName);
50     void ThreadGetPss() const;
51     void TriggerGetPss() const;
52     void SetFirstFlag();
53     void SetProcessId(const std::string &pid);
54 private:
RAM()55     RAM() {};
56     RAM(const RAM &);
57     RAM &operator = (const RAM &);
58     std::string packageName = "";
59     std::string processId = "";
60 };
61 }
62 }
63 #endif
64