Apollo
10.0
自动驾驶开放平台
block.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/block.h
"
18
19
#include "
cyber/profiler/block_manager.h
"
20
21
namespace
apollo
{
22
namespace
cyber {
23
namespace
profiler {
24
25
Block::Block
() : depth_(0), begin_time_(), end_time_() {}
26
27
Block::Block
(
const
std::string& name)
28
: name_(name), depth_(0), begin_time_(), end_time_() {}
29
30
Block::~Block
() {
31
if
(!
finished
())
32
BlockManager::Instance()->EndBlock();
33
}
34
35
void
Block::Start
() {
36
begin_time_ = std::chrono::steady_clock::now();
37
}
38
39
void
Block::End
() {
40
end_time_ = std::chrono::steady_clock::now();
41
}
42
43
std::uint64_t
Block::begin_time_since_epoch
()
const
{
44
return
std::chrono::duration_cast<std::chrono::nanoseconds>(
45
begin_time_.time_since_epoch()).count();
46
}
47
48
std::uint64_t
Block::end_time_since_epoch
()
const
{
49
return
std::chrono::duration_cast<std::chrono::nanoseconds>(
50
end_time_.time_since_epoch()).count();
51
}
52
53
std::uint64_t
Block::duration
()
const
{
54
return
std::chrono::duration_cast<std::chrono::nanoseconds>(
55
end_time_ - begin_time_).count();
56
}
57
58
}
// namespace profiler
59
}
// namespace cyber
60
}
// namespace apollo
block_manager.h
apollo::cyber::profiler::Block::duration
std::uint64_t duration() const
Definition
block.cc:53
apollo::cyber::profiler::Block::~Block
virtual ~Block()
Definition
block.cc:30
apollo::cyber::profiler::Block::end_time_since_epoch
std::uint64_t end_time_since_epoch() const
Definition
block.cc:48
apollo::cyber::profiler::Block::begin_time_since_epoch
std::uint64_t begin_time_since_epoch() const
Definition
block.cc:43
apollo::cyber::profiler::Block::Block
Block()
Definition
block.cc:25
apollo::cyber::profiler::Block::Start
void Start()
Definition
block.cc:35
apollo::cyber::profiler::Block::finished
bool finished() const
Definition
block.h:50
apollo::cyber::profiler::Block::End
void End()
Definition
block.cc:39
apollo
class register implement
Definition
arena_queue.h:37
block.h
cyber
profiler
block.cc