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> SaveSumRamInfo(std::vector<std::string> paramsInfo) const; 41 std::map<std::string, std::string> ProcMemNaInfo() const; GetInstance()42 static RAM &GetInstance() 43 { 44 static RAM instance; 45 return instance; 46 } 47 std::map<std::string, std::string> ItemData() override; 48 void SetPackageName(const std::string &pName); 49 void ThreadGetPss() const; 50 void TriggerGetPss() const; 51 void SetFirstFlag(); 52 void SetProcessId(const std::string &pid); 53 private: RAM()54 RAM() {}; 55 RAM(const RAM &); 56 RAM &operator = (const RAM &); 57 std::string packageName = ""; 58 std::string processId = ""; 59 }; 60 } 61 } 62 #endif 63