添加性能监控

This commit is contained in:
aozhiwei 2020-06-29 10:25:49 +08:00
parent c5fc298caf
commit bb4120b289
3 changed files with 10 additions and 3 deletions

View File

@ -19,7 +19,6 @@ static void SavePerfLog()
App::Instance()->msgnode_size_,
PerfMonitor::Instance()->read_count,
PerfMonitor::Instance()->max_login_time,
PerfMonitor::Instance()->max_join_time,
});
a8::UdpLog::Instance()->Info(" run_times:%d timer_times:%d event_times:%d free_times:%d "
" shutdown_times:%d connect_times:%d close_times:%d "
@ -40,7 +39,6 @@ static void SavePerfLog()
PerfMonitor::Instance()->max_run_delay_time = 0;
PerfMonitor::Instance()->max_timer_idle = 0;
PerfMonitor::Instance()->max_login_time = 0;
PerfMonitor::Instance()->max_join_time = 0;
}
void PerfMonitor::Init()

View File

@ -11,7 +11,8 @@ class PerfMonitor : public a8::Singleton<PerfMonitor>
int max_dispatchmsg_time = 0;
int max_timer_idle = 0;
long long max_login_time = 0;
long long max_join_time = 0;
long long login_ok_times = 0;
long long login_error_times = 0;
long long out_data_size = 0;
long long in_data_size = 0;
long long read_count = 0;

View File

@ -12,6 +12,7 @@
#include "gamelog.h"
#include "IMListener.h"
#include "typeconvert.h"
#include "perfmonitor.h"
#include "framework/cpp/utils.h"
@ -171,6 +172,7 @@ void PlayerMgr::_CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg)
return;
}
f8::MsgHdr* new_hdr = hdr.Clone();
new_hdr->user_data = (const void*)a8::XGetTickCount();
pending_socket_hash_[hdr.socket_handle] = std::make_tuple(msg.account_id(), new_hdr);
pending_account_hash_[msg.account_id()] = new_hdr;
AsyncLogin1(msg);
@ -475,8 +477,13 @@ void PlayerMgr::AsyncLoginOnOk(const std::string& account_id,
respmsg.set_errmsg("ok");
hum->SendMsg(respmsg);
}
long long login_tick = a8::XGetTickCount() - (long long)hdr->user_data;
if (login_tick > PerfMonitor::Instance()->max_login_time) {
PerfMonitor::Instance()->max_login_time = login_tick;
}
f8::MsgHdr::Destroy(hdr);
}
++PerfMonitor::Instance()->login_ok_times;
}
void PlayerMgr::AsyncLoginOnError(const std::string& account_id, int step,
@ -488,6 +495,7 @@ void PlayerMgr::AsyncLoginOnError(const std::string& account_id, int step,
pending_account_hash_.erase(account_id);
f8::MsgHdr::Destroy(hdr);
}
++PerfMonitor::Instance()->login_error_times;
}
void PlayerMgr::OnClientSocketDisconnect(int socket_handle)