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
18
20
21namespace apollo {
22namespace cyber {
23namespace profiler {
24
25Block::Block() : depth_(0), begin_time_(), end_time_() {}
26
27Block::Block(const std::string& name)
28 : name_(name), depth_(0), begin_time_(), end_time_() {}
29
31 if (!finished())
32 BlockManager::Instance()->EndBlock();
33}
34
36 begin_time_ = std::chrono::steady_clock::now();
37}
38
39void Block::End() {
40 end_time_ = std::chrono::steady_clock::now();
41}
42
43std::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
48std::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
53std::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
std::uint64_t duration() const
Definition block.cc:53
std::uint64_t end_time_since_epoch() const
Definition block.cc:48
std::uint64_t begin_time_since_epoch() const
Definition block.cc:43
class register implement
Definition arena_queue.h:37