1 /* 2 * Copyright (c) 2025 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 16 #ifndef PERF_REPORTER_H 17 #define PERF_REPORTER_H 18 19 #include "perf_constants.h" 20 #include "perf_model.h" 21 22 #include "transaction/rs_render_service_client.h" 23 24 namespace OHOS { 25 namespace HiviewDFX { 26 27 class PerfReporter { 28 public: 29 static PerfReporter& GetInstance(); 30 void ReportJankFrameApp(double jank, int32_t jankThreshold); 31 void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName, const std::string& pageName); 32 void ReportAnimatorEvent(PerfEventType type, DataBase& data); 33 void ReportSingleJankFrame(JankInfo& jankInfo); 34 void ReportStatsJankFrame(int64_t jankFrameRecordBeginTime, int64_t duration, 35 const std::vector<uint16_t>& jankFrameRecord, int32_t jankFrameTotalCount, const BaseInfo& baseInfo); 36 void ReportWhiteBlockStat(uint64_t scrollStartTime, uint64_t scrollEndTime, 37 const std::map<int64_t, ImageLoadInfo*>& mRecords); 38 void ReportSurface(const int64_t& uniqueId, const std::string& surfaceName, const std::string& componentName, 39 const std::string& bundleName, const int32_t& pid); 40 41 private: 42 void ConvertToRsData(OHOS::Rosen::DataBaseRs &dataRs, DataBase& data); 43 void FlushDataBase(AnimatorRecord* record, DataBase& data); 44 void ReportPerfEventToRS(DataBase& data); 45 void ReportPerfEventToUI(DataBase data); 46 }; 47 48 class EventReporter { 49 public: 50 static void ReportJankFrameApp(JankInfo& info); 51 static void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName, 52 const std::string& pageName); 53 static void ReportEventComplete(DataBase& data); 54 static void ReportEventJankFrame(DataBase& data); 55 static void ReportJankFrameFiltered(JankInfo& info); 56 static void ReportJankFrameUnFiltered(JankInfo& info); 57 static void ReportStatsJankFrame(int64_t startTime, int64_t duration, const std::vector<uint16_t>& jank, 58 const BaseInfo& baseInfo, uint32_t jankStatusVersion = 1); 59 #ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 60 static void ReportAppFrameDropToRss(const bool isInteractionJank, const std::string &bundleName, 61 const int64_t maxFrameTime = 0); 62 #endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 63 64 static void ReportImageLoadStat(const ImageLoadStat& stat); 65 static void ReportSurfaceInfo(const SurfaceInfo& surface); 66 }; 67 } 68 } 69 70 #endif