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