Apollo 10.0
自动驾驶开放平台
block.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_BLOCK_H_
18#define CYBER_PROFILER_BLOCK_H_
19
20#include <chrono>
21#include <string>
22
23namespace apollo {
24namespace cyber {
25namespace profiler {
26
27class Block {
28 public:
29 using time_point = std::chrono::time_point<std::chrono::steady_clock>;
30
31 public:
32 Block();
33 explicit Block(const std::string& name);
34 virtual ~Block();
35
36 void Start();
37 void End();
38
39 const std::string& name() const { return name_; }
40 std::uint32_t depth() const { return depth_; }
41 void set_depth(std::uint32_t depth) { depth_ = depth; }
42
43 const time_point& begin_time() const { return begin_time_; }
44 const time_point& end_time() const { return end_time_; }
45
46 std::uint64_t begin_time_since_epoch() const;
47 std::uint64_t end_time_since_epoch() const;
48 std::uint64_t duration() const;
49
50 bool finished() const { return end_time_ > begin_time_; }
51
52 private:
53 std::string name_;
54 std::uint32_t depth_;
55 time_point begin_time_;
56 time_point end_time_;
57};
58
59} // namespace profiler
60} // namespace cyber
61} // namespace apollo
62
63#endif // CYBER_PROFILER_BLOCK_H_
const std::string & name() const
Definition block.h:39
std::uint64_t duration() const
Definition block.cc:53
const time_point & end_time() const
Definition block.h:44
std::uint64_t end_time_since_epoch() const
Definition block.cc:48
const time_point & begin_time() const
Definition block.h:43
std::uint64_t begin_time_since_epoch() const
Definition block.cc:43
void set_depth(std::uint32_t depth)
Definition block.h:41
std::uint32_t depth() const
Definition block.h:40
std::chrono::time_point< std::chrono::steady_clock > time_point
Definition block.h:29
class register implement
Definition arena_queue.h:37