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 namespace OHOS { 19 namespace SmartPerf { 20 class ByTrace { 21 public: GetInstance()22 static ByTrace &GetInstance() 23 { 24 static ByTrace instance; 25 return instance; 26 } 27 // trace配置 28 void SetTraceConfig(int mSum, int mInterval, long long mThreshold, int mLowfps, int mCurNum) const; 29 // 开始抓trace线程 30 void ThreadGetTrace() const; 31 // trace命令配置 32 void SetTraceCmd(std::string traceCmd) const; 33 // 校验fps-jitters 34 TraceStatus CheckFpsJitters(std::vector<long long> jitters, int cfps); 35 // 触发trace 36 void TriggerCatch(long long curTime) const; 37 38 private: ByTrace()39 ByTrace() {}; 40 ByTrace(const ByTrace &); 41 ByTrace &operator = (const ByTrace &); 42 43 // 抓trace总次数 默认2次 44 mutable int sum = 2; 45 // 当前触发的次数 46 mutable int curNum = 1; 47 // 抓trace间隔(两次抓取的间隔时间 默认60*1000 ms) 48 mutable int interval = 60000; 49 // 抓trace触发条件:默认 某一帧的某个jitter>100 ms触发 50 mutable long long threshold = 100; 51 // 上一次触发时间 52 mutable long long lastTriggerTime = -1; 53 // 当前是否触发 54 mutable long long currentTrigger = -1; 55 //traceCmd 56 mutable std::string traceCmd = ""; 57 //低帧触发 58 mutable int lowfps = -1; 59 //前2秒采的不准 60 mutable int times = 0; 61 }; 62 } 63 } 64 #endif