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
17
#include "
cyber/profiler/frame.h
"
18
19
#include <utility>
20
21
#include "
cyber/common/log.h
"
22
23
namespace
apollo
{
24
namespace
cyber {
25
namespace
profiler {
26
27
constexpr
char
kModuleName
[] =
"perf"
;
28
29
void
Frame::Push
(
Block
* block) {
30
if
(block !=
nullptr
)
31
stack_.push(block);
32
}
33
34
Block
*
Frame::Top
() {
35
if
(stack_.empty())
36
return
nullptr
;
37
return
stack_.top();
38
}
39
40
void
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
49
bool
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_) {
53
ALOG_MODULE
(
kModuleName
, INFO)
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
61
void
Frame::Clear
() {
62
storage_.clear();
63
}
64
65
}
// namespace profiler
66
}
// namespace cyber
67
}
// namespace apollo
apollo::cyber::profiler::Block
Definition
block.h:27
apollo::cyber::profiler::Frame::Pop
void Pop()
Definition
frame.cc:40
apollo::cyber::profiler::Frame::Clear
void Clear()
Definition
frame.cc:61
apollo::cyber::profiler::Frame::Top
Block * Top()
Definition
frame.cc:34
apollo::cyber::profiler::Frame::Push
void Push(Block *block)
Definition
frame.cc:29
apollo::cyber::profiler::Frame::DumpToFile
bool DumpToFile(const std::string &coroutine_name)
Definition
frame.cc:49
frame.h
log.h
ALOG_MODULE
#define ALOG_MODULE(module, log_severity)
Definition
log.h:52
apollo::cyber::profiler::kModuleName
constexpr char kModuleName[]
Definition
frame.cc:27
apollo
class register implement
Definition
arena_queue.h:37
cyber
profiler
frame.cc