提交 5635ad0a 编写于 作者: Z zhangchao19 提交者: GoLancer

framework: format and lint code for perf event

上级 b288f0a9
...@@ -29,7 +29,7 @@ namespace event { ...@@ -29,7 +29,7 @@ namespace event {
using apollo::cybertron::base::BoundedQueue; using apollo::cybertron::base::BoundedQueue;
using apollo::cybertron::common::GlobalData; using apollo::cybertron::common::GlobalData;
void SchedPerfEvent::SetParams(int count, ...) { void SchedPerfEvent::SetParams(const int count, ...) {
va_list ap; va_list ap;
va_start(ap, count); va_start(ap, count);
event_id = va_arg(ap, int); event_id = va_arg(ap, int);
...@@ -43,7 +43,7 @@ void SchedPerfEvent::SetParams(int count, ...) { ...@@ -43,7 +43,7 @@ void SchedPerfEvent::SetParams(int count, ...) {
va_end(ap); va_end(ap);
} }
void TransportPerfEvent::SetParams(int count, ...) { void TransportPerfEvent::SetParams(const int count, ...) {
va_list ap; va_list ap;
va_start(ap, count); va_start(ap, count);
event_id = va_arg(ap, int); event_id = va_arg(ap, int);
......
...@@ -51,20 +51,13 @@ enum class SchedPerf { ...@@ -51,20 +51,13 @@ enum class SchedPerf {
enum class TransPerf { TRANS_FROM = 1, TRANS_TO = 2, WRITE_NOTIFY = 3 }; enum class TransPerf { TRANS_FROM = 1, TRANS_TO = 2, WRITE_NOTIFY = 3 };
// event_id
// 1 swap_in
// 2 swap_out
// 3 try_fetch_out
// 4 notify_in
// 5 next_routine
class PerfEventBase { class PerfEventBase {
public: public:
int event_type = 0; int event_type = 0;
int event_id; int event_id;
uint64_t t_start = -1; uint64_t t_start = -1;
uint64_t t_end = -1; uint64_t t_end = -1;
virtual void SetParams(int count, ...) { virtual void SetParams(const int count, ...) {
va_list ap; va_list ap;
va_start(ap, count); va_start(ap, count);
event_type = va_arg(ap, int); event_type = va_arg(ap, int);
...@@ -92,7 +85,7 @@ class PerfEventBase { ...@@ -92,7 +85,7 @@ class PerfEventBase {
class SchedPerfEvent : public PerfEventBase { class SchedPerfEvent : public PerfEventBase {
public: public:
SchedPerfEvent() { event_type = int(EventType::SCHED_EVENT); } SchedPerfEvent() { event_type = int(EventType::SCHED_EVENT); }
void SetParams(int count, ...) override; void SetParams(const int count, ...) override;
std::string SerializeToString() override { std::string SerializeToString() override {
std::stringstream ss; std::stringstream ss;
ss << event_type << "\t"; ss << event_type << "\t";
...@@ -121,7 +114,7 @@ class SchedPerfEvent : public PerfEventBase { ...@@ -121,7 +114,7 @@ class SchedPerfEvent : public PerfEventBase {
class TransportPerfEvent : public PerfEventBase { class TransportPerfEvent : public PerfEventBase {
public: public:
TransportPerfEvent() { event_type = int(EventType::TRANS_EVENT); } TransportPerfEvent() { event_type = int(EventType::TRANS_EVENT); }
void SetParams(int count, ...) override; void SetParams(const int count, ...) override;
std::string SerializeToString() override { std::string SerializeToString() override {
std::stringstream ss; std::stringstream ss;
ss << event_type << "\t"; ss << event_type << "\t";
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <unordered_map> #include <unordered_map>
#include "cybertron/event/perf_event_cache.h" #include "cybertron/event/perf_event_cache.h"
#include "cybertron/common/global_data.h" #include "cybertron/common/global_data.h"
#include "cybertron/init.h" #include "cybertron/init.h"
#include "cybertron/time/time.h" #include "cybertron/time/time.h"
...@@ -65,10 +64,12 @@ void PerfEventCache::AddEvent(const std::shared_ptr<PerfEventBase>& event) { ...@@ -65,10 +64,12 @@ void PerfEventCache::AddEvent(const std::shared_ptr<PerfEventBase>& event) {
} }
} }
void PerfEventCache::AddSchedEvent(SchedPerf event_id, uint64_t cr_id, void PerfEventCache::AddSchedEvent(const SchedPerf event_id,
int proc_id, uint64_t t_sleep, const uint64_t cr_id, const int proc_id,
uint64_t t_start, int try_fetch_result, const uint64_t t_sleep,
int croutine_state) { const uint64_t t_start,
const int try_fetch_result,
const int croutine_state) {
if (!enable_) { if (!enable_) {
return; return;
} }
...@@ -85,8 +86,9 @@ void PerfEventCache::AddSchedEvent(SchedPerf event_id, uint64_t cr_id, ...@@ -85,8 +86,9 @@ void PerfEventCache::AddSchedEvent(SchedPerf event_id, uint64_t cr_id,
} }
} }
void PerfEventCache::AddTransportEvent(TransPerf event_id, uint64_t channel_id, void PerfEventCache::AddTransportEvent(const TransPerf event_id,
uint64_t msg_seq) { const uint64_t channel_id,
const uint64_t msg_seq) {
if (!enable_) { if (!enable_) {
return; return;
} }
......
...@@ -44,11 +44,12 @@ using apollo::cybertron::proto::PerfConf; ...@@ -44,11 +44,12 @@ using apollo::cybertron::proto::PerfConf;
class PerfEventCache { class PerfEventCache {
public: public:
~PerfEventCache(); ~PerfEventCache();
void AddSchedEvent(SchedPerf event_id, uint64_t cr_id, int proc_id, void AddSchedEvent(const SchedPerf event_id, const uint64_t cr_id,
uint64_t t_sleep, uint64_t t_start, int try_fetch_result, const int proc_id, const uint64_t t_sleep,
int croutine_state); const uint64_t t_start, const int try_fetch_result,
void AddTransportEvent(TransPerf event_id, uint64_t channel_id, const int croutine_state);
uint64_t msg_seq); void AddTransportEvent(const TransPerf event_id, const uint64_t channel_id,
const uint64_t msg_seq);
void AddEvent(const std::shared_ptr<PerfEventBase>& event); void AddEvent(const std::shared_ptr<PerfEventBase>& event);
private: private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册