添加性能监控日志

This commit is contained in:
aozhiwei 2020-07-03 14:40:32 +08:00
parent 8f289ea48f
commit 2408f952be
3 changed files with 41 additions and 28 deletions

View File

@ -5,12 +5,15 @@
#include "perfmonitor.h" #include "perfmonitor.h"
#include "app.h" #include "app.h"
#include "playermgr.h"
#include "dbhelper.h"
static void SavePerfLog() static void SavePerfLog()
{ {
a8::UdpLog::Instance()->Info(" max_run_delay_time:%d max_timer_idle:%d " a8::UdpLog::Instance()->Info
("max_run_delay_time:%d max_timer_idle:%d "
"in_data_size:%d out_data_size:%d msgnode_size:%d read_count:%d max_login_time:%d " "in_data_size:%d out_data_size:%d msgnode_size:%d read_count:%d max_login_time:%d "
"max_join_time:%d", "max_join_time:%d online_num:%d watch_num:%d cache_users_num:%d ",
{ {
PerfMonitor::Instance()->max_run_delay_time, PerfMonitor::Instance()->max_run_delay_time,
PerfMonitor::Instance()->max_timer_idle, PerfMonitor::Instance()->max_timer_idle,
@ -19,8 +22,12 @@ static void SavePerfLog()
App::Instance()->msgnode_size_, App::Instance()->msgnode_size_,
PerfMonitor::Instance()->read_count, PerfMonitor::Instance()->read_count,
PerfMonitor::Instance()->max_login_time, PerfMonitor::Instance()->max_login_time,
PlayerMgr::Instance()->OnlineNum(),
PlayerMgr::Instance()->WatchPlayerNum(),
DBHelper::Instance()->cache_users_hash.size()
}); });
a8::UdpLog::Instance()->Info(" run_times:%d timer_times:%d event_times:%d free_times:%d " 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 " "shutdown_times:%d connect_times:%d close_times:%d "
"send_times:%d recv_times:%d error_times:%d immsg_times:%d", "send_times:%d recv_times:%d error_times:%d immsg_times:%d",
{ {

View File

@ -237,6 +237,11 @@ int PlayerMgr::OnlineNum()
return socket_hash_.size(); return socket_hash_.size();
} }
int PlayerMgr::WatchPlayerNum()
{
return watch_players_.size();
}
void PlayerMgr::Update(long long tick) void PlayerMgr::Update(long long tick)
{ {
for (auto& pair : accountid_hash_) { for (auto& pair : accountid_hash_) {

View File

@ -62,6 +62,7 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
void WatchPlayer(Friend* friend_data); void WatchPlayer(Friend* friend_data);
void UnWatchPlayer(Friend* friend_data); void UnWatchPlayer(Friend* friend_data);
int OnlineNum(); int OnlineNum();
int WatchPlayerNum();
void Update(long long tick); void Update(long long tick);
private: private: