• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 
16 #ifndef NETWORK_H
17 #define NETWORK_H
18 #include "sp_profiler.h"
19 #include <string>
20 namespace OHOS {
21 namespace SmartPerf {
22 class Network : public SpProfiler {
23 public:
24     std::map<std::string, std::string> ItemData() override;
GetInstance()25     static Network &GetInstance()
26     {
27         static Network instance;
28         return instance;
29     }
30     std::map<std::string, std::string> GetNetworkInfo();
31     void GetCurNetwork(long long &networkCurRx, long long &networkCurTx);
32     void IsFindHap();
33     void IsStopFindHap();
34     void ThreadGetHapNetwork();
35     void ClearHapFlag();
36     void ThreadFunctions();
37     std::map<std::string, std::string> GetNetworkInfoDev();
38 private:
Network()39     Network() {};
40     Network(const Network &);
41     Network &operator = (const Network &);
42     std::map<std::string, std::string> result = {};
43     long long rmnetCurRx = 0;
44     long long rmnetCurTx = 0;
45     long long ethCurRx = 0;
46     long long ethCurTx = 0;
47     long long wlanCurRx = 0;
48     long long wlanCurTx = 0;
49     long long allTx = 0;
50     long long allRx = 0;
51     long long curTx = 0;
52     long long curRx = 0;
53     long long diffTx = 0;
54     long long diffRx = 0;
55     bool isFirst = true;
56     bool hapFlag = false;
57     bool stophapFlag = false;
58 };
59 }
60 }
61 #endif // NETWORK_H
62