Apollo 10.0
自动驾驶开放平台
latency_recorder.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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#pragma once
18
19#include <memory>
20#include <mutex>
21#include <string>
22
23#include "cyber/cyber.h"
24
25#include "modules/common/latency_recorder/proto/latency_record.pb.h"
26
27namespace apollo {
28namespace common {
29
31 public:
32 explicit LatencyRecorder(const std::string& module_name);
33
34 void AppendLatencyRecord(const uint64_t message_id,
35 const apollo::cyber::Time& begin_time,
36 const apollo::cyber::Time& end_time);
37
38 private:
39 LatencyRecorder() = default;
40 std::shared_ptr<apollo::cyber::Writer<LatencyRecordMap>> CreateWriter();
41 void PublishLatencyRecords(
42 const std::shared_ptr<apollo::cyber::Writer<LatencyRecordMap>>& writer);
43
44 std::string module_name_;
45 std::mutex mutex_;
46 std::unique_ptr<LatencyRecordMap> records_;
47 apollo::cyber::Time current_time_;
48 std::shared_ptr<apollo::cyber::Node> node_;
49};
50
51} // namespace common
52} // namespace apollo
void AppendLatencyRecord(const uint64_t message_id, const apollo::cyber::Time &begin_time, const apollo::cyber::Time &end_time)
Cyber has builtin time type Time.
Definition time.h:31
class register implement
Definition arena_queue.h:37