Apollo 10.0
自动驾驶开放平台
profiler.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef CYBER_PROFILER_PROFILER_H_
18#define CYBER_PROFILER_PROFILER_H_
19
22
23namespace apollo {
24namespace cyber {
25namespace profiler {
26
27#if ENABLE_PROFILER
28
29#if defined(__GNUC__) || defined(__GNUG__)
30#define AFUNC __PRETTY_FUNCTION__
31#elif defined(__clang__)
32#define AFUNC __PRETTY_FUNCTION__
33#else
34#define AFUNC __func__
35#endif
36
37#define TOKEN_JOIN(x, y) x ## y
38#define UNIQUE_NAME(x) TOKEN_JOIN(prefix_perf, x)
39
40#define PERF_BLOCK(name, ...) \
41 apollo::cyber::profiler::Block UNIQUE_NAME(__LINE__)(name); \
42 apollo::cyber::profiler::BlockManager::Instance()->StartBlock( \
43 &UNIQUE_NAME(__LINE__));
44
45#define PERF_BLOCK_END \
46 apollo::cyber::profiler::BlockManager::Instance()->EndBlock();
47
48#define PERF_FUNCTION(...) PERF_BLOCK(AFUNC, ## __VA_ARGS__)
49
50#else
51
52#define PERF_BLOCK(...)
53#define PERF_BLOCK_END
54#define PERF_FUNCTION(...)
55
56#endif // #if ENABLE_PROFILER
57
58} // namespace profiler
59} // namespace cyber
60} // namespace apollo
61
62#endif // CYBER_PROFILER_PROFILER_H_
class register implement
Definition arena_queue.h:37