• 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 #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) const;
29     // 开始抓trace线程
30     void ThreadGetTrace() const;
31     // 结束trace线程
32     void ThreadEndTrace() const;
33     // 结束抓trace线程
34     void ThreadFinishTrace(const std::string &pathName) const;
35     // 校验fps-jitters
36     TraceStatus CheckFpsJitters(std::vector<long long> jitters);
37     // 触发trace
38     void TriggerCatch(long long curTime) const;
39 
40 private:
ByTrace()41     ByTrace() {};
42     ByTrace(const ByTrace &);
43     ByTrace &operator = (const ByTrace &);
44 
45     // 抓trace总次数 默认2次
46     mutable int sum = 2;
47     // 当前触发的次数
48     mutable int curNum = 0;
49     // 抓trace间隔(两次抓取的间隔时间 默认60*1000 ms)
50     mutable int interval = 60000;
51     // 抓trace耗时(start 到 finish的预留时间 默认10*1000 ms)
52     mutable int cost = 10000;
53     // 抓trace触发条件:默认 某一帧的某个jitter>100 ms触发
54     mutable long long threshold = 100;
55     // 上一次触发时间
56     mutable long long lastTriggerTime = -1;
57     // 当前是否触发
58     mutable long long curTriggerFlag = -1;
59 };
60 }
61 }
62 #endif