• 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 #ifndef STALLINGRATETRACE_H
16 #define STALLINGRATETRACE_H
17 #include <iostream>
18 #include <fstream>
19 #include <string>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace SmartPerf {
24 class StallingRateTrace {
25 public:
26     enum SWIM_TYPE {
27         SWIM_APPLIST = 1,
28         SWIM_APPSWIPER = 2,
29         SWIM_APPTABS = 3,
30     };
31 public:
32     double StallingRateResult(const std::string& file);
33     double CalculateTime();
34     double GetFrameRate(const std::string &line) const;
35     int GetFenceId(const std::string &line) const;
36     std::string GetOnScreenTimeStart(const std::string &line) const;
37     double GetTimes(const std::string &line, const std::string &sign) const;
38     void AppList(const std::string &line, const std::string &signS, const std::string &signF);
39     void APPTabs(const std::string &line, const std::string &signS, const std::string &signF);
40     void AppSwiperScroll(const std::string &line, const std::string &signS, const std::string &signF);
41     void GetRsHardWareRate(double curFrameRate, const std::string &line, SWIM_TYPE type);
42     void GetFrameLossTime(double &curTime, double &prevTime, double &drawTime, double &totalFrameLossTime);
43     void CalcFrameRate();
44     void JudgFrameRate();
45     void MultiLaneFrameRate();
46     void AddMultiLaneFrameRate();
47     void UpdateRoundTime(double curFrameRate, SWIM_TYPE type);
48     bool IsAppLaunchPatternMatched(const std::string &line);
49 private:
50     std::ifstream infile;
51     double nowFrameRate = 0;
52     double nowSwiperFrameRate = 0;
53     double nowTabsFrameRate = 0;
54     double oneThousand = 1000;
55     double roundTime = 0;
56     double roundSwiperTime = 0;
57     double roundTabsTime = 0;
58     int fenceId = 0;
59     int fenceIdSwiper = 0;
60     int fenceIdTabs = 0;
61     double nowTime = 0;
62     double nowSwiperTime = 0;
63     double nowTabsTime = 0;
64     double lastTime = 0;
65     double lastSwiperTime = 0;
66     double lastTabsTime = 0;
67     double frameLossTime = 0;
68     double frameLossRate = 0;
69     double frameLossSwiperTime = 0;
70     double frameLossTabsTime = 0;
71     double swiperFrameLossRate = 0;
72     double appFrameLossRate = 0;
73     double tabsFrameLossRate = 0;
74     double appListDynamicStartTime = 0;
75     double appListDynamicFinishTime = 0;
76     double appTabsDynamicStartTime = 0;
77     double appTabsDynamicFinishTime = 0;
78     double swiperDynamicStartTime = 0;
79     double swiperDynamicFinishTime = 0;
80     bool upperScreenFlag = false;
81     bool upperScreenSwiperFlag = false;
82     bool upperScreenTabsFlag = false;
83     int swiperScrollFlag = 0;
84     int swiperFlingFlag = 0;
85     bool listFlag = false;
86     bool tabsFlag = false;
87     bool swiperFlag = false;
88 };
89 }
90 }
91 #endif // STALLINGRATETRACE_H