1 /*
2  * Copyright (c) 2020-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 
16 #ifndef GRAPHIC_LITE_PERFORMANCE_TASK_H
17 #define GRAPHIC_LITE_PERFORMANCE_TASK_H
18 
19 #include "graphic_config.h"
20 #if ENABLE_DEBUG && ENABLE_DEBUG_PERFORMANCE_TRACE
21 #include "common/task.h"
22 #include "graphic_performance.h"
23 
24 namespace OHOS {
25 class PerformanceTask : public Task {
26 public:
27     static PerformanceTask* GetInstance();
28 
Init()29     void Init() override
30     {
31         Performance::GetInstance()->RegisterSIGUSR1();
32         Task::Init();
33     }
34 
Callback()35     void Callback() override
36     {
37         Performance::GetInstance()->PrintResult();
38     }
39 private:
PerformanceTask()40     PerformanceTask() {}
~PerformanceTask()41     virtual ~PerformanceTask() {}
42     PerformanceTask(const PerformanceTask&) = delete;
43     PerformanceTask& operator=(const PerformanceTask&) = delete;
44     PerformanceTask(PerformanceTask&&) = delete;
45     PerformanceTask& operator=(PerformanceTask&&) = delete;
46 };
47 }
48 #define DEBUG_PERFORMANCE_TASK_INIT() OHOS::PerformanceTask::GetInstance()->Init()
49 #else
50 #define DEBUG_PERFORMANCE_TASK_INIT()
51 #endif
52 #endif