Apollo  6.0
Open source self driving car software
latency_monitor.h
Go to the documentation of this file.
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 <set>
21 #include <string>
22 #include <tuple>
23 #include <unordered_map>
24 
25 #include "modules/common/latency_recorder/proto/latency_record.pb.h"
27 
28 namespace apollo {
29 namespace monitor {
30 
32  public:
34  void RunOnce(const double current_time) override;
35  bool GetFrequency(const std::string& channel_name, double* freq);
36 
37  private:
38  void UpdateStat(
39  const std::shared_ptr<apollo::common::LatencyRecordMap>& records);
40  void PublishLatencyReport();
41  void AggregateLatency();
42 
43  apollo::common::LatencyReport latency_report_;
44  std::unordered_map<uint64_t,
45  std::set<std::tuple<uint64_t, uint64_t, std::string>>>
46  track_map_;
47  std::unordered_map<std::string, double> freq_map_;
48  double flush_time_ = 0.0;
49 };
50 
51 } // namespace monitor
52 } // namespace apollo
Definition: latency_monitor.h:31
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool GetFrequency(const std::string &channel_name, double *freq)
Definition: recurrent_runner.h:28
void RunOnce(const double current_time) override