Apollo 10.0
自动驾驶开放平台
frame.cc
浏览该文件的文档.
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
18
19#include <utility>
20
21#include "cyber/common/log.h"
22
23namespace apollo {
24namespace cyber {
25namespace profiler {
26
27constexpr char kModuleName[] = "perf";
28
29void Frame::Push(Block* block) {
30 if (block != nullptr)
31 stack_.push(block);
32}
33
35 if (stack_.empty())
36 return nullptr;
37 return stack_.top();
38}
39
40void Frame::Pop() {
41 if (stack_.empty())
42 return;
43
44 Block* block_ptr = stack_.top();
45 stack_.pop();
46 storage_.push_back(std::move(*block_ptr));
47}
48
49bool Frame::DumpToFile(const std::string& routine_name) {
50 // Use 'ALOG_MODULE' instead of 'AINFO' to specify the log file
51 ALOG_MODULE(kModuleName, INFO) << "Frame : " << routine_name;
52 for (const Block& block : storage_) {
54 << block.depth() << "," << block.name() << "," << block.duration()
55 << "," << block.begin_time_since_epoch()
56 << "," << block.end_time_since_epoch();
57 }
58 return true;
59}
60
62 storage_.clear();
63}
64
65} // namespace profiler
66} // namespace cyber
67} // namespace apollo
void Push(Block *block)
Definition frame.cc:29
bool DumpToFile(const std::string &coroutine_name)
Definition frame.cc:49
#define ALOG_MODULE(module, log_severity)
Definition log.h:52
constexpr char kModuleName[]
Definition frame.cc:27
class register implement
Definition arena_queue.h:37