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 BY_TRACE_H 16 #define BY_TRACE_H 17 #include "common.h" 18 #include <fstream> 19 #include "sp_profiler.h" 20 namespace OHOS { 21 namespace SmartPerf { 22 class ByTrace : public SpProfiler { 23 public: GetInstance()24 static ByTrace &GetInstance() 25 { 26 static ByTrace instance; 27 return instance; 28 } 29 std::map<std::string, std::string> ItemData() override; 30 // 校验fps-jitters 31 void CheckFpsJitters(long long& jitters, int cfps); 32 void SetByTrace(); 33 void ClearTraceFiles() const; 34 void RemoveTraceFiles() const; 35 void CpTraceFile() const; 36 long long GetThreshold() const; 37 int GetLowFps() const; 38 void SendSurfaceCaton(long long& jitters, int cfps); 39 static inline std::string jittersAndLowFps = ""; 40 static inline std::string hiviewTrace = ""; 41 public: 42 long long lastEnableTime = 0; 43 std::string traceCpPath_ {"/data/local/tmp/hitrace"}; 44 long long nowTime = 0; 45 int times = 0; 46 private: ByTrace()47 ByTrace() {}; 48 ByTrace(const ByTrace &); 49 ByTrace &operator = (const ByTrace &); 50 51 const std::string hiviewTracePath_ {"/data/log/hiview/unified_collection/trace/special/"}; 52 53 long long jitterTimesTaken = 0; 54 int lowFps = -1; 55 }; 56 } 57 } 58 #endif