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
16 #include "base/log/ace_trace.h"
17
18 #include "hitrace_meter.h"
19
20 #include "base/log/log.h"
21 #include "base/utils/macros.h"
22 #include "base/utils/system_properties.h"
23 #include "base/utils/utils.h"
24
25 namespace OHOS::Ace {
26
AceTraceEnabled()27 bool AceTraceEnabled()
28 {
29 return true;
30 }
31
AceTraceBegin(const char * name)32 void AceTraceBegin(const char* name)
33 {
34 CHECK_NULL_VOID_NOLOG(name);
35 std::string nameStr(name);
36 StartTrace(HITRACE_TAG_ACE, nameStr);
37 }
38
AceTraceEnd()39 void AceTraceEnd()
40 {
41 FinishTrace(HITRACE_TAG_ACE);
42 }
43
AceAsyncTraceBegin(int32_t taskId,const char * name)44 void AceAsyncTraceBegin(int32_t taskId, const char* name)
45 {
46 CHECK_NULL_VOID_NOLOG(name);
47 std::string nameStr(name);
48 StartAsyncTrace(HITRACE_TAG_ACE, nameStr, taskId);
49 }
50
AceAsyncTraceEnd(int32_t taskId,const char * name)51 void AceAsyncTraceEnd(int32_t taskId, const char* name)
52 {
53 CHECK_NULL_VOID_NOLOG(name);
54 std::string nameStr(name);
55 FinishAsyncTrace(HITRACE_TAG_ACE, nameStr, taskId);
56 }
57 } // namespace OHOS::Ace
58