Apollo 11.0
自动驾驶开放平台
process_statistic_component.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#pragma once
18
19#include <memory>
20#include <regex>
21#include <string>
22#include <unordered_map>
23#include <vector>
24
25#include "modules/statistics_msgs/process_statistic.pb.h"
26
28#include "cyber/cyber.h"
29
34namespace apollo {
35namespace process_statistic {
36
37const auto mainboard_dag_regex = std::regex("-d ([\\w/\\.-]+)");
38const auto mainboard_process_regex = std::regex("-p ([\\w-]+)");
39const uint8_t cache_clean_cycles = 60;
40
42 uint64_t timestamp;
43 std::vector<std::string> mainboard_dags;
44 std::string mainboard_process;
45 std::string general_process;
46};
47
49public:
50 bool Init() override;
51 bool Proc() override;
52
53private:
54 // load conf
55 void LoadConf(const ProcessStatisticConf& conf);
56 std::vector<std::regex> general_process_regex_list_;
57
58 // cache
59 bool ParseFromCache(const std::string& cmd_string, std::shared_ptr<ProcessMetrics> metrics);
60 void CleanCache();
61 std::unordered_map<std::string, std::shared_ptr<CacheMetric>> cache_;
62 uint8_t cycles = 0;
63
64 // parse command
65 void ParseCmd(
66 const std::string& cmd_string,
67 std::shared_ptr<ProcessMetrics> metrics,
68 std::shared_ptr<CacheMetric> cache_metric);
69
70 std::shared_ptr<cyber::Writer<ProcessMetrics>> metric_writer_;
71};
72
74
75} // namespace process_statistic
76} // namespace apollo
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
class register implement
Definition arena_queue.h:37