Apollo 10.0
自动驾驶开放平台
apollo::common::LatencyRecorder类 参考

#include <latency_recorder.h>

apollo::common::LatencyRecorder 的协作图:

Public 成员函数

 LatencyRecorder (const std::string &module_name)
 
void AppendLatencyRecord (const uint64_t message_id, const apollo::cyber::Time &begin_time, const apollo::cyber::Time &end_time)
 

详细描述

在文件 latency_recorder.h30 行定义.

构造及析构函数说明

◆ LatencyRecorder()

apollo::common::LatencyRecorder::LatencyRecorder ( const std::string &  module_name)
explicit

在文件 latency_recorder.cc28 行定义.

29 : module_name_(module_name) {
30 records_.reset(new LatencyRecordMap);
31}

成员函数说明

◆ AppendLatencyRecord()

void apollo::common::LatencyRecorder::AppendLatencyRecord ( const uint64_t  message_id,
const apollo::cyber::Time begin_time,
const apollo::cyber::Time end_time 
)

在文件 latency_recorder.cc33 行定义.

35 {
36 // TODO(michael): ALERT for now for trouble shooting,
37 // CHECK_LT(begin_time, end_time) in the future to enforce the validation
38 if (begin_time >= end_time) {
39 // In Simulation mode, there might be large number of cases where
40 // begin_time == end_time, reduce the error frequency in this mode
41 static const int kErrorReduceBase = 1000;
42
43 // FIXME(storypku): IsRealityMode|MockTime
44 if (!cyber::common::GlobalData::Instance()->IsRealityMode()) {
45 AERROR_EVERY(kErrorReduceBase) << "latency begin_time: " << begin_time
46 << " >= end_time: " << end_time << ", "
47 << kErrorReduceBase << " times";
48 return;
49 }
50 AERROR << "latency begin_time: " << begin_time
51 << " >= end_time: " << end_time;
52 return;
53 }
54
55 static auto writer = CreateWriter();
56 if (writer == nullptr || message_id == 0) {
57 return;
58 }
59
60 std::lock_guard<std::mutex> lock(mutex_);
61
62 auto* latency_record = records_->add_latency_records();
63 latency_record->set_begin_time(begin_time.ToNanosecond());
64 latency_record->set_end_time(end_time.ToNanosecond());
65 latency_record->set_message_id(message_id);
66
67 const auto now = Clock::Now();
68 const apollo::cyber::Duration kPublishInterval(3.0);
69 if (now - current_time_ > kPublishInterval) {
70 PublishLatencyRecords(writer);
71 current_time_ = now;
72 }
73}
static Time Now()
PRECISION >= 1000000 means the precision is at least 1us.
Definition clock.cc:40
uint64_t ToNanosecond() const
convert time to nanosecond.
Definition time.cc:83
#define AERROR
Definition log.h:44
#define AERROR_EVERY(freq)
Definition log.h:86

该类的文档由以下文件生成: