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 // 校验fps-jitters 32 TraceStatus CheckFpsJitters(std::vector<long long> jitters, int cfps) const; 33 // 触发trace 34 void TriggerCatch(long long curTime) const; 35 bool CheckHitraceId() const; 36 37 private: ByTrace()38 ByTrace() {}; 39 ByTrace(const ByTrace &); 40 ByTrace &operator = (const ByTrace &); 41 42 // 抓trace总次数 默认2次 43 mutable int sum = 2; 44 // 当前触发的次数 45 mutable int curNum = 1; 46 // 抓trace间隔(两次抓取的间隔时间 默认60*1000 ms) 47 mutable int interval = 60000; 48 // 抓trace触发条件:默认 某一帧的某个jitter>100 ms触发 49 mutable long long threshold = 100; 50 // 上一次触发时间 51 mutable long long lastTriggerTime = -1; 52 // 当前是否触发 53 mutable long long currentTrigger = -1; 54 // 低帧触发 55 mutable int lowfps = -1; 56 // 前2秒采的不准 57 mutable int times = 0; 58 }; 59 } 60 } 61 #endif