• 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(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 private:
49     std::ifstream infile;
50     double nowFrameRate = 0;
51     double nowSwiperFrameRate = 0;
52     double nowTabsFrameRate = 0;
53     double oneThousand = 1000;
54     double roundTime = 0;
55     double roundSwiperTime = 0;
56     double roundTabsTime = 0;
57     int fenceId = 0;
58     int fenceIdSwiper = 0;
59     int fenceIdTabs = 0;
60     double nowTime = 0;
61     double nowSwiperTime = 0;
62     double nowTabsTime = 0;
63     double lastTime = 0;
64     double lastSwiperTime = 0;
65     double lastTabsTime = 0;
66     double frameLossTime = 0;
67     double frameLossRate = 0;
68     double frameLossSwiperTime = 0;
69     double frameLossTabsTime = 0;
70     double swiperFrameLossRate = 0;
71     double appFrameLossRate = 0;
72     double tabsFrameLossRate = 0;
73     double appListDynamicStartTime = 0;
74     double appListDynamicFinishTime = 0;
75     double appTabsDynamicStartTime = 0;
76     double appTabsDynamicFinishTime = 0;
77     double swiperDynamicStartTime = 0;
78     double swiperDynamicFinishTime = 0;
79     bool upperScreenFlag = false;
80     bool upperScreenSwiperFlag = false;
81     bool upperScreenTabsFlag = false;
82     int swiperScrollFlag = 0;
83     int swiperFlingFlag = 0;
84     bool listFlag = false;
85     bool tabsFlag = false;
86     bool swiperFlag = false;
87 };
88 }
89 }
90 #endif // STALLINGRATETRACE_H