• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SP_PARSE_FPS_H
16 #define SP_PARSE_FPS_H
17 #include <iostream>
18 #include <fstream>
19 #include <vector>
20 #include <queue>
21 #include <regex>
22 #include <cstdio>
23 #include <string>
24 #include <memory>
25 using SpString = std::string;
26 using FpsResult = SpString;
27 using FilePath = const SpString;
28 using PackageName = const SpString;
29 using FileSteamPtr = std::shared_ptr<std::ifstream>;
30 using Line = SpString;
31 typedef enum {
32     VIDEO,
33     WEB,
34     LARGE
35 } PageType;
36 #define PARAMS_EMPTY "params invalided!"
37 #define FILE_OPEN_FAILED "file open failed!"
38 #define TOUCHEVENT_FLAG "H:touchEventDispatch"
39 #define HTOUCHEVENT_FLAG "H:TouchEventDispatch"
40 #define ROSENRENDERWEB "H:RosenRenderWeb:"
41 #define ROSENRENDERTEXTURE "H:RosenRenderTexture:"
42 #define FLING "fling"
43 class SpParseFPS {
44 public:
45     SpParseFPS();
46     ~SpParseFPS();
47 
48 private:
49     struct RecordFpsVars {
50         // moveResponseTime - moveStartTime
51         int frameNum = 0;
52         unsigned int tEventDisNum = 0;
53         // The start point of the first frame after the hand is off
54         SpString leaveStartTime = "0";
55         // the last point
56         SpString leaveEndTime = "0";
57         // the last touchDis point's time
58         SpString lastTouchEventTime = "0";
59         // After the first frame after the hand is left to start rendering add, the end of the add is terminated
60         bool isAddFrame = false;
61         // DoComposition has the dot corresponding to the package name under the calculation end time
62         bool isHasUI = false;
63         // Start fetching the start point of the hand
64         bool isStaticsLeaveTime = false;
65         // The start time is taken once
66         int startFlag = 0;
67         FpsResult complexFps;
68         SpString pidMatchStr;
69     };
70     struct TouchEvent {
TouchEventTouchEvent71         TouchEvent()
72         {
73             tEventDisNum = 0;
74             touchFlag = false;
75         }
76         unsigned int tEventDisNum;
77         bool touchFlag;
78     };
79 
80 public:
81     FpsResult ParseTraceFile(FilePath &filePath, PackageName &packageName);
82 
83 private:
84     inline unsigned int GetTouchEventNum(Line &line, TouchEvent &touchEvent) const;
85     inline void StrSplit(const SpString &content, const SpString &sp, std::vector<SpString> &out) const;
86     inline void GetAndSetPageType(Line &line, PageType &pageType) const;
87     inline const FpsResult ParseBranch(FilePath &filePath, PackageName &pN, PageType &pT, TouchEvent &tE);
88     inline FpsResult PraseFPSTrace(FilePath &filePath, float staticTime, SpString uiPoint);
89     // Gets the statistical off start time marker bits
90     inline void DecHandOffTime(Line &line);
91     // Statistics of the start time of the handout
92     inline void StaticHandoffStartTime(Line &line);
93     // Count the number of rendered frames and the end time
94     inline bool CountRsEndTime(Line &line, float staticTime, SpString uiPoint);
95 
96     const SpString videoPoint = "H:RSUniRender::Process:[RosenRenderTexture]";
97     const SpString webPoint = "H:RSUniRender::Process:[RosenRenderWeb]";
98     const SpString sysUiPoint = "H:RSUniRender::Process:[SystemUi_ControlPanel]";
99     const SpString doPoint = "H:RSMainThread::DoComposition";
100     const SpString uniProcess = "H:RSUniRender::Process:[";
101 
102     std::regex pattern;
103     // filter pid
104     std::regex pidPattern;
105 
106 private:
107     PageType pageTypeClient;
108     Line lineClient;
109     TouchEvent touchEventClient;
110     RecordFpsVars rfV;
111     std::queue<SpString> beQueue;
112 };
113 #endif
114