Apollo 10.0
自动驾驶开放平台
perf_event_cache.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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_EVENT_PERF_EVENT_CACHE_H_
18#define CYBER_EVENT_PERF_EVENT_CACHE_H_
19
20#include <chrono>
21#include <fstream>
22#include <memory>
23#include <string>
24#include <thread>
25
26#include "cyber/proto/perf_conf.pb.h"
27
29#include "cyber/common/macros.h"
31
32namespace apollo {
33namespace cyber {
34namespace event {
35
37 public:
38 using EventBasePtr = std::shared_ptr<EventBase>;
39
41 void AddSchedEvent(const SchedPerf event_id, const uint64_t cr_id,
42 const int proc_id, const int cr_state = -1);
43 void AddTransportEvent(const TransPerf event_id, const uint64_t channel_id,
44 const uint64_t msg_seq, const uint64_t stamp = 0,
45 const std::string& adder = "-");
46
47 std::string PerfFile() { return perf_file_; }
48
49 void Shutdown();
50
51 private:
52 void Start();
53 void Run();
54
55 std::thread io_thread_;
56 std::ofstream of_;
57
58 bool enable_ = false;
59 bool shutdown_ = false;
60
61 proto::PerfConf perf_conf_;
62 std::string perf_file_ = "";
64
65 const int kFlushSize = 512;
66 const uint64_t kEventQueueSize = 8192;
67
69};
70
71} // namespace event
72} // namespace cyber
73} // namespace apollo
74
75#endif // CYBER_EVENT_PERF_EVENT_CACHE_H_
void AddSchedEvent(const SchedPerf event_id, const uint64_t cr_id, const int proc_id, const int cr_state=-1)
std::shared_ptr< EventBase > EventBasePtr
void AddTransportEvent(const TransPerf event_id, const uint64_t channel_id, const uint64_t msg_seq, const uint64_t stamp=0, const std::string &adder="-")
#define DECLARE_SINGLETON(classname)
Definition macros.h:52
class register implement
Definition arena_queue.h:37