add perfmonitor
This commit is contained in:
parent
d1a1cb8de9
commit
1c010e9b5f
@ -11,7 +11,7 @@ Android::Android():Human()
|
|||||||
ai = new AndroidAI;
|
ai = new AndroidAI;
|
||||||
ai->owner = this;
|
ai->owner = this;
|
||||||
#if 0
|
#if 0
|
||||||
++App::Instance()->perf.entity_num[ET_Android];
|
++PerfMonitor::Instance()->entity_num[ET_Android];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ Android::~Android()
|
|||||||
delete ai;
|
delete ai;
|
||||||
ai = nullptr;
|
ai = nullptr;
|
||||||
#if 0
|
#if 0
|
||||||
--App::Instance()->perf.entity_num[ET_Android];
|
--PerfMonitor::Instance()->entity_num[ET_Android];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "mapmgr.h"
|
#include "mapmgr.h"
|
||||||
#include "entityfactory.h"
|
#include "entityfactory.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
#include "ss_msgid.pb.h"
|
#include "ss_msgid.pb.h"
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
@ -56,31 +57,35 @@ const char* const PROJ_LOG_FILENAME_FMT = "log_$pid_%Y%m%d.log";
|
|||||||
static void SavePerfLog()
|
static void SavePerfLog()
|
||||||
{
|
{
|
||||||
a8::UdpLog::Instance()->Info
|
a8::UdpLog::Instance()->Info
|
||||||
("mainloop_rundelay:%d room_num:%d player_num:%d online_num:%d alive_count:%d "
|
("rundelay:%d room_num:%d player_num:%d online_num:%d alive_count:%d "
|
||||||
"sys_request_delay:%d user_request_delay:%d http_pending_num:%d real_alive_count:%d",
|
"sys_request_delay:%d user_request_delay:%d http_pending_num:%d real_alive_count:%d "
|
||||||
|
"account_num:%d level0_num:%d level1_num:%d",
|
||||||
{
|
{
|
||||||
App::Instance()->perf.max_run_delay_time,
|
PerfMonitor::Instance()->max_run_delay_time,
|
||||||
RoomMgr::Instance()->RoomNum(),
|
RoomMgr::Instance()->RoomNum(),
|
||||||
App::Instance()->perf.entity_num[ET_Player],
|
PerfMonitor::Instance()->entity_num[ET_Player],
|
||||||
PlayerMgr::Instance()->OnlineNum(),
|
PlayerMgr::Instance()->OnlineNum(),
|
||||||
App::Instance()->perf.alive_count,
|
PerfMonitor::Instance()->alive_count,
|
||||||
f8::HttpClientPool::Instance()->max_sys_request_delay,
|
f8::HttpClientPool::Instance()->max_sys_request_delay,
|
||||||
f8::HttpClientPool::Instance()->max_user_request_delay,
|
f8::HttpClientPool::Instance()->max_user_request_delay,
|
||||||
f8::HttpClientPool::Instance()->GetPendingNum(),
|
f8::HttpClientPool::Instance()->GetPendingNum(),
|
||||||
App::Instance()->perf.real_alive_count
|
PerfMonitor::Instance()->real_alive_count,
|
||||||
|
PlayerMgr::Instance()->GetAccountNum(),
|
||||||
|
PerfMonitor::Instance()->room_num[RT_NewBrid],
|
||||||
|
PerfMonitor::Instance()->room_num[RT_MidBrid]
|
||||||
});
|
});
|
||||||
App::Instance()->perf.max_run_delay_time = 0;
|
PerfMonitor::Instance()->max_run_delay_time = 0;
|
||||||
App::Instance()->perf.max_dispatchmsg_time = 0;
|
PerfMonitor::Instance()->max_dispatchmsg_time = 0;
|
||||||
App::Instance()->perf.max_timer_idle = 0;
|
PerfMonitor::Instance()->max_timer_idle = 0;
|
||||||
App::Instance()->perf.grid_chg_times = 0;
|
PerfMonitor::Instance()->grid_chg_times = 0;
|
||||||
App::Instance()->perf.test_times = 0;
|
PerfMonitor::Instance()->test_times = 0;
|
||||||
App::Instance()->perf.params[0] = 0,
|
PerfMonitor::Instance()->params[0] = 0,
|
||||||
App::Instance()->perf.params[1] = 0,
|
PerfMonitor::Instance()->params[1] = 0,
|
||||||
App::Instance()->perf.params[2] = 0,
|
PerfMonitor::Instance()->params[2] = 0,
|
||||||
App::Instance()->perf.params[3] = 0,
|
PerfMonitor::Instance()->params[3] = 0,
|
||||||
App::Instance()->perf.params[4] = 0,
|
PerfMonitor::Instance()->params[4] = 0,
|
||||||
App::Instance()->perf.params[5] = 0,
|
PerfMonitor::Instance()->params[5] = 0,
|
||||||
App::Instance()->perf.params[6] = 0,
|
PerfMonitor::Instance()->params[6] = 0,
|
||||||
f8::HttpClientPool::Instance()->max_sys_request_delay = 0;
|
f8::HttpClientPool::Instance()->max_sys_request_delay = 0;
|
||||||
f8::HttpClientPool::Instance()->max_user_request_delay = 0;
|
f8::HttpClientPool::Instance()->max_user_request_delay = 0;
|
||||||
}
|
}
|
||||||
@ -123,6 +128,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
|
|
||||||
srand(time(nullptr));
|
srand(time(nullptr));
|
||||||
InitLog();
|
InitLog();
|
||||||
|
PerfMonitor::Instance()->Init();
|
||||||
HandlerMgr::Instance()->Init();
|
HandlerMgr::Instance()->Init();
|
||||||
a8::Timer::Instance()->Init();
|
a8::Timer::Instance()->Init();
|
||||||
f8::MsgQueue::Instance()->Init();
|
f8::MsgQueue::Instance()->Init();
|
||||||
@ -178,6 +184,7 @@ void App::UnInit()
|
|||||||
f8::MsgQueue::Instance()->UnInit();
|
f8::MsgQueue::Instance()->UnInit();
|
||||||
a8::Timer::Instance()->UnInit();
|
a8::Timer::Instance()->UnInit();
|
||||||
HandlerMgr::Instance()->UnInit();
|
HandlerMgr::Instance()->UnInit();
|
||||||
|
PerfMonitor::Instance()->UnInit();
|
||||||
f8::TGLog::Instance()->UnInit();
|
f8::TGLog::Instance()->UnInit();
|
||||||
UnInitLog();
|
UnInitLog();
|
||||||
|
|
||||||
@ -202,8 +209,8 @@ int App::Run()
|
|||||||
SlowerExecute(delta_time);
|
SlowerExecute(delta_time);
|
||||||
Schedule();
|
Schedule();
|
||||||
a8::tick_t end_tick = a8::XGetTickCount();
|
a8::tick_t end_tick = a8::XGetTickCount();
|
||||||
if (end_tick - begin_tick > perf.max_run_delay_time) {
|
if (end_tick - begin_tick > PerfMonitor::Instance()->max_run_delay_time) {
|
||||||
perf.max_run_delay_time = end_tick - begin_tick;
|
PerfMonitor::Instance()->max_run_delay_time = end_tick - begin_tick;
|
||||||
}
|
}
|
||||||
delta_time = end_tick - begin_tick;
|
delta_time = end_tick - begin_tick;
|
||||||
}
|
}
|
||||||
@ -366,8 +373,8 @@ void App::DispatchMsg()
|
|||||||
}
|
}
|
||||||
#ifdef PERFT
|
#ifdef PERFT
|
||||||
a8::tick_t end_tick = a8::XGetTickCount();
|
a8::tick_t end_tick = a8::XGetTickCount();
|
||||||
if (end_tick - begin_tick > perf.max_dispatchmsg_time) {
|
if (end_tick - begin_tick > PerfMonitor::Instance()->max_dispatchmsg_time) {
|
||||||
perf.max_dispatchmsg_time = end_tick - begin_tick;
|
PerfMonitor::Instance()->max_dispatchmsg_time = end_tick - begin_tick;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ public:
|
|||||||
int argc = 0;
|
int argc = 0;
|
||||||
char** argv = nullptr;
|
char** argv = nullptr;
|
||||||
volatile bool terminated = false;
|
volatile bool terminated = false;
|
||||||
PerfMonitor perf;
|
|
||||||
a8::uuid::SnowFlake uuid;
|
a8::uuid::SnowFlake uuid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -8,15 +8,16 @@
|
|||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
#include "mapservice.h"
|
#include "mapservice.h"
|
||||||
#include "cs_proto.pb.h"
|
#include "cs_proto.pb.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
Building::Building():Entity()
|
Building::Building():Entity()
|
||||||
{
|
{
|
||||||
++App::Instance()->perf.entity_num[ET_Building];
|
++PerfMonitor::Instance()->entity_num[ET_Building];
|
||||||
}
|
}
|
||||||
|
|
||||||
Building::~Building()
|
Building::~Building()
|
||||||
{
|
{
|
||||||
--App::Instance()->perf.entity_num[ET_Building];
|
--PerfMonitor::Instance()->entity_num[ET_Building];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Building::Initialize()
|
void Building::Initialize()
|
||||||
|
@ -7,15 +7,16 @@
|
|||||||
#include "obstacle.h"
|
#include "obstacle.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
Bullet::Bullet():MoveableEntity()
|
Bullet::Bullet():MoveableEntity()
|
||||||
{
|
{
|
||||||
++App::Instance()->perf.entity_num[ET_Bullet];
|
++PerfMonitor::Instance()->entity_num[ET_Bullet];
|
||||||
}
|
}
|
||||||
|
|
||||||
Bullet::~Bullet()
|
Bullet::~Bullet()
|
||||||
{
|
{
|
||||||
--App::Instance()->perf.entity_num[ET_Bullet];
|
--PerfMonitor::Instance()->entity_num[ET_Bullet];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bullet::Initialize()
|
void Bullet::Initialize()
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "building.h"
|
#include "building.h"
|
||||||
#include "human.h"
|
#include "human.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
Entity::Entity()
|
Entity::Entity()
|
||||||
{
|
{
|
||||||
@ -36,7 +37,7 @@ void Entity::GetCircleBox(CircleCollider& circle_box)
|
|||||||
|
|
||||||
bool Entity::TestCollision(Room* room, Entity* b)
|
bool Entity::TestCollision(Room* room, Entity* b)
|
||||||
{
|
{
|
||||||
App::Instance()->perf.test_times++;
|
PerfMonitor::Instance()->test_times++;
|
||||||
if (b->IsDead(room)) {
|
if (b->IsDead(room)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "cs_proto.pb.h"
|
#include "cs_proto.pb.h"
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
@ -20,8 +21,8 @@ static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
|||||||
request->resp_xobj->SetVal("errmsg", "");
|
request->resp_xobj->SetVal("errmsg", "");
|
||||||
request->resp_xobj->SetVal("healthy", 1);
|
request->resp_xobj->SetVal("healthy", 1);
|
||||||
request->resp_xobj->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
request->resp_xobj->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
||||||
request->resp_xobj->SetVal("max_rundelay", App::Instance()->perf.max_run_delay_time);
|
request->resp_xobj->SetVal("max_rundelay", PerfMonitor::Instance()->max_run_delay_time);
|
||||||
request->resp_xobj->SetVal("max_timer_idle", App::Instance()->perf.max_timer_idle);
|
request->resp_xobj->SetVal("max_timer_idle", PerfMonitor::Instance()->max_timer_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _GMOpsReload(f8::JsonHttpRequest* request)
|
static void _GMOpsReload(f8::JsonHttpRequest* request)
|
||||||
@ -59,7 +60,7 @@ static void _GMStatGetRealTimeOnline(f8::JsonHttpRequest* request)
|
|||||||
{
|
{
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
request->resp_xobj->SetVal("errcode", 0);
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
request->resp_xobj->SetVal("errmsg", "");
|
||||||
request->resp_xobj->SetVal("num", App::Instance()->perf.entity_num[ET_Player]);
|
request->resp_xobj->SetVal("num", PerfMonitor::Instance()->entity_num[ET_Player]);
|
||||||
request->resp_xobj->SetVal("room_num", RoomMgr::Instance()->RoomNum());
|
request->resp_xobj->SetVal("room_num", RoomMgr::Instance()->RoomNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,15 +7,16 @@
|
|||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
Loot::Loot():RoomEntity()
|
Loot::Loot():RoomEntity()
|
||||||
{
|
{
|
||||||
++App::Instance()->perf.entity_num[ET_Loot];
|
++PerfMonitor::Instance()->entity_num[ET_Loot];
|
||||||
}
|
}
|
||||||
|
|
||||||
Loot::~Loot()
|
Loot::~Loot()
|
||||||
{
|
{
|
||||||
--App::Instance()->perf.entity_num[ET_Loot];
|
--PerfMonitor::Instance()->entity_num[ET_Loot];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loot::Initialize()
|
void Loot::Initialize()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
enum ObstacleDataFlags_e
|
enum ObstacleDataFlags_e
|
||||||
{
|
{
|
||||||
@ -17,12 +18,12 @@ enum ObstacleDataFlags_e
|
|||||||
|
|
||||||
Obstacle::Obstacle():Entity()
|
Obstacle::Obstacle():Entity()
|
||||||
{
|
{
|
||||||
++App::Instance()->perf.entity_num[ET_Obstacle];
|
++PerfMonitor::Instance()->entity_num[ET_Obstacle];
|
||||||
}
|
}
|
||||||
|
|
||||||
Obstacle::~Obstacle()
|
Obstacle::~Obstacle()
|
||||||
{
|
{
|
||||||
--App::Instance()->perf.entity_num[ET_Obstacle];
|
--PerfMonitor::Instance()->entity_num[ET_Obstacle];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Obstacle::Initialize()
|
void Obstacle::Initialize()
|
||||||
|
13
server/gameserver/perfmonitor.cc
Normal file
13
server/gameserver/perfmonitor.cc
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
|
void PerfMonitor::Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerfMonitor::UnInit()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
26
server/gameserver/perfmonitor.h
Normal file
26
server/gameserver/perfmonitor.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class PerfMonitor : public a8::Singleton<PerfMonitor>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
PerfMonitor() {};
|
||||||
|
friend class a8::Singleton<PerfMonitor>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
int max_run_delay_time = 0;
|
||||||
|
int max_dispatchmsg_time = 0;
|
||||||
|
int max_timer_idle = 0;
|
||||||
|
long long out_data_size = 0;
|
||||||
|
long long in_data_size = 0;
|
||||||
|
long long read_count = 0;
|
||||||
|
long long grid_chg_times = 0;
|
||||||
|
long long test_times = 0;
|
||||||
|
long long alive_count = 0;
|
||||||
|
long long real_alive_count = 0;
|
||||||
|
std::array<long long, 30> params = {};
|
||||||
|
std::array<int, 30> entity_num = {};
|
||||||
|
std::array<int, RT_Max + 1> room_num = {};
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void UnInit();
|
||||||
|
};
|
@ -14,17 +14,20 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "collider.h"
|
#include "collider.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
|
#include "playermgr.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
const int kREVIVE_BUFF_ID = 1005;
|
const int kREVIVE_BUFF_ID = 1005;
|
||||||
|
|
||||||
Player::Player():Human()
|
Player::Player():Human()
|
||||||
{
|
{
|
||||||
++App::Instance()->perf.entity_num[ET_Player];
|
++PerfMonitor::Instance()->entity_num[ET_Player];
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player()
|
||||||
{
|
{
|
||||||
--App::Instance()->perf.entity_num[ET_Player];
|
--PerfMonitor::Instance()->entity_num[ET_Player];
|
||||||
|
PlayerMgr::Instance()->DecAccountNum(account_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Initialize()
|
void Player::Initialize()
|
||||||
|
@ -142,3 +142,50 @@ void PlayerMgr::RemovePlayerBySocket(int socket_handle)
|
|||||||
socket_hash_.erase(itr);
|
socket_hash_.erase(itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::IncAccountNum(const std::string& account_id)
|
||||||
|
{
|
||||||
|
auto itr = account_num_hash_.find(account_id);
|
||||||
|
if (itr != account_num_hash_.end()) {
|
||||||
|
++(itr->second);
|
||||||
|
if (itr->second > 3) {
|
||||||
|
a8::UdpLog::Instance()->Warning
|
||||||
|
(
|
||||||
|
"IncAccountNum account_id:%s num:%d > 3",
|
||||||
|
{
|
||||||
|
account_id,
|
||||||
|
itr->second
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
account_num_hash_[account_id] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::DecAccountNum(const std::string& account_id)
|
||||||
|
{
|
||||||
|
auto itr = account_num_hash_.find(account_id);
|
||||||
|
if (itr != account_num_hash_.end()) {
|
||||||
|
--(itr->second);
|
||||||
|
if (itr->second < 0) {
|
||||||
|
a8::UdpLog::Instance()->Warning
|
||||||
|
(
|
||||||
|
"DecAccountNum account_id:%s num:%d < 0",
|
||||||
|
{
|
||||||
|
account_id,
|
||||||
|
itr->second
|
||||||
|
}
|
||||||
|
);
|
||||||
|
account_num_hash_.erase(itr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a8::UdpLog::Instance()->Warning
|
||||||
|
(
|
||||||
|
"DecAccountNum account_id:%s not exits",
|
||||||
|
{
|
||||||
|
account_id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -33,7 +33,11 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
|||||||
Player* CreatePlayerByCMJoin(Player* hum, long ip_saddr, int socket, const cs::CMJoin& msg);
|
Player* CreatePlayerByCMJoin(Player* hum, long ip_saddr, int socket, const cs::CMJoin& msg);
|
||||||
void OnClientDisconnect(a8::XParams& param);
|
void OnClientDisconnect(a8::XParams& param);
|
||||||
void RemovePlayerBySocket(int socket_handle);
|
void RemovePlayerBySocket(int socket_handle);
|
||||||
|
size_t GetAccountNum() { return account_num_hash_.size(); }
|
||||||
|
void IncAccountNum(const std::string& account_id);
|
||||||
|
void DecAccountNum(const std::string& account_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<int, Player*> socket_hash_;
|
std::map<int, Player*> socket_hash_;
|
||||||
|
std::map<std::string, int> account_num_hash_;
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
#include "entityfactory.h"
|
#include "entityfactory.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
const int ROOM_MAX_PLAYER_NUM = 40;
|
const int ROOM_MAX_PLAYER_NUM = 40;
|
||||||
const int SHUA_RANGE = 731;
|
const int SHUA_RANGE = 731;
|
||||||
@ -97,7 +98,7 @@ void Room::UnInit()
|
|||||||
}
|
}
|
||||||
removed_robot_hash_.clear();
|
removed_robot_hash_.clear();
|
||||||
grid_service->ClearRoomData(this);
|
grid_service->ClearRoomData(this);
|
||||||
App::Instance()->perf.alive_count -= alive_count_;
|
PerfMonitor::Instance()->alive_count -= alive_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::Update(int delta_time)
|
void Room::Update(int delta_time)
|
||||||
@ -188,7 +189,7 @@ void Room::AddPlayer(Player* hum)
|
|||||||
MatchTeam(hum);
|
MatchTeam(hum);
|
||||||
hum->PushJoinRoomMsg();
|
hum->PushJoinRoomMsg();
|
||||||
++alive_count_;
|
++alive_count_;
|
||||||
++App::Instance()->perf.alive_count;
|
++PerfMonitor::Instance()->alive_count;
|
||||||
|
|
||||||
grid_service->AddHuman(hum);
|
grid_service->AddHuman(hum);
|
||||||
hum->FindLocation();
|
hum->FindLocation();
|
||||||
@ -285,7 +286,7 @@ void Room::CreateAndroid(int robot_num)
|
|||||||
AddToHumanHash(hum);
|
AddToHumanHash(hum);
|
||||||
MatchTeam(hum);
|
MatchTeam(hum);
|
||||||
++alive_count_;
|
++alive_count_;
|
||||||
++App::Instance()->perf.alive_count;
|
++PerfMonitor::Instance()->alive_count;
|
||||||
refreshed_robot_set_.insert(robot_meta->i->id());
|
refreshed_robot_set_.insert(robot_meta->i->id());
|
||||||
|
|
||||||
if (!CanAddToScene(hum)) {
|
if (!CanAddToScene(hum)) {
|
||||||
@ -494,7 +495,7 @@ void Room::RemoveObjectLater(RoomEntity* entity)
|
|||||||
void Room::OnHumanDie(Human* hum)
|
void Room::OnHumanDie(Human* hum)
|
||||||
{
|
{
|
||||||
--alive_count_;
|
--alive_count_;
|
||||||
--App::Instance()->perf.alive_count;
|
--PerfMonitor::Instance()->alive_count;
|
||||||
RemoveFromAliveHumanHash(hum);
|
RemoveFromAliveHumanHash(hum);
|
||||||
NotifyUiUpdate();
|
NotifyUiUpdate();
|
||||||
}
|
}
|
||||||
@ -1288,7 +1289,7 @@ void Room::RandRemoveAndroid()
|
|||||||
RemoveFromHuamnHash(hum);
|
RemoveFromHuamnHash(hum);
|
||||||
AddToRemovedRobotHash(hum);
|
AddToRemovedRobotHash(hum);
|
||||||
--alive_count_;
|
--alive_count_;
|
||||||
--App::Instance()->perf.alive_count;
|
--PerfMonitor::Instance()->alive_count;
|
||||||
for (auto& pair : human_hash_) {
|
for (auto& pair : human_hash_) {
|
||||||
pair.second->RemovePartObjects(hum);
|
pair.second->RemovePartObjects(hum);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "mapmgr.h"
|
#include "mapmgr.h"
|
||||||
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
#include "framework/cpp/httpclientpool.h"
|
#include "framework/cpp/httpclientpool.h"
|
||||||
#include "framework/cpp/utils.h"
|
#include "framework/cpp/utils.h"
|
||||||
@ -76,7 +77,7 @@ void RoomMgr::Update(int delta_time)
|
|||||||
room->Update(delta_time);
|
room->Update(delta_time);
|
||||||
real_alive_count += room->RealAliveCount();
|
real_alive_count += room->RealAliveCount();
|
||||||
}
|
}
|
||||||
App::Instance()->perf.real_alive_count = real_alive_count;
|
PerfMonitor::Instance()->real_alive_count = real_alive_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||||
@ -102,6 +103,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
hum->ProcPrepareItems(msg.prepare_items());
|
hum->ProcPrepareItems(msg.prepare_items());
|
||||||
hum->ProcPrepareItems2(msg.prepare_items2());
|
hum->ProcPrepareItems2(msg.prepare_items2());
|
||||||
room->AddPlayer(hum);
|
room->AddPlayer(hum);
|
||||||
|
PlayerMgr::Instance()->IncAccountNum(msg.account_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
int RoomMgr::RoomNum()
|
int RoomMgr::RoomNum()
|
||||||
@ -241,7 +243,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
|
|||||||
url_params->SetVal("port", JsonDataMgr::Instance()->listen_port);
|
url_params->SetVal("port", JsonDataMgr::Instance()->listen_port);
|
||||||
url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum());
|
url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum());
|
||||||
url_params->SetVal("room_num", RoomNum());
|
url_params->SetVal("room_num", RoomNum());
|
||||||
url_params->SetVal("alive_count", App::Instance()->perf.real_alive_count);
|
url_params->SetVal("alive_count", PerfMonitor::Instance()->real_alive_count);
|
||||||
url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
||||||
f8::HttpClientPool::Instance()->HttpGet(a8::XParams()
|
f8::HttpClientPool::Instance()->HttpGet(a8::XParams()
|
||||||
.SetSender(instance_id)
|
.SetSender(instance_id)
|
||||||
@ -260,6 +262,7 @@ void RoomMgr::FreeOverRoom(long long room_uuid)
|
|||||||
{
|
{
|
||||||
auto itr = over_room_hash_.find(room_uuid);
|
auto itr = over_room_hash_.find(room_uuid);
|
||||||
if (itr != over_room_hash_.end()) {
|
if (itr != over_room_hash_.end()) {
|
||||||
|
--PerfMonitor::Instance()->room_num[itr->second->GetRoomType()];
|
||||||
itr->second->UnInit();
|
itr->second->UnInit();
|
||||||
room_idx_hash_.erase(itr->second->GetRoomIdx());
|
room_idx_hash_.erase(itr->second->GetRoomIdx());
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
@ -299,7 +302,7 @@ bool RoomMgr::IsLimitJoin()
|
|||||||
{
|
{
|
||||||
return RoomNum() >= ROOM_NUM_UP_LIMIT ||
|
return RoomNum() >= ROOM_NUM_UP_LIMIT ||
|
||||||
(
|
(
|
||||||
App::Instance()->perf.real_alive_count >= HUM_NUM_DOWN_LIMIT
|
PerfMonitor::Instance()->real_alive_count >= HUM_NUM_DOWN_LIMIT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,6 +344,7 @@ Room* RoomMgr::CreateRoom(RoomType_e room_type)
|
|||||||
inactive_room_hash_[room->GetRoomUuid()] = room;
|
inactive_room_hash_[room->GetRoomUuid()] = room;
|
||||||
room_hash_[room->GetRoomUuid()] = room;
|
room_hash_[room->GetRoomUuid()] = room;
|
||||||
room_idx_hash_[room->GetRoomIdx()] = room;
|
room_idx_hash_[room->GetRoomIdx()] = room;
|
||||||
|
++PerfMonitor::Instance()->room_num[room->GetRoomType()];
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
a8::UdpLog::Instance()->Debug("createroom room_idx:%d room_uuid:%d room_type:%d",
|
a8::UdpLog::Instance()->Debug("createroom room_idx:%d room_uuid:%d room_type:%d",
|
||||||
{
|
{
|
||||||
@ -375,9 +379,9 @@ void RoomMgr::JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_
|
|||||||
{
|
{
|
||||||
error_code,
|
error_code,
|
||||||
msg.account_id(),
|
msg.account_id(),
|
||||||
App::Instance()->perf.max_run_delay_time,
|
PerfMonitor::Instance()->max_run_delay_time,
|
||||||
RoomMgr::Instance()->RoomNum(),
|
RoomMgr::Instance()->RoomNum(),
|
||||||
App::Instance()->perf.entity_num[ET_Player],
|
PerfMonitor::Instance()->entity_num[ET_Player],
|
||||||
PlayerMgr::Instance()->OnlineNum(),
|
PlayerMgr::Instance()->OnlineNum(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct PerfMonitor
|
|
||||||
{
|
|
||||||
int max_run_delay_time = 0;
|
|
||||||
int max_dispatchmsg_time = 0;
|
|
||||||
int max_timer_idle = 0;
|
|
||||||
long long out_data_size = 0;
|
|
||||||
long long in_data_size = 0;
|
|
||||||
long long read_count = 0;
|
|
||||||
long long grid_chg_times = 0;
|
|
||||||
long long test_times = 0;
|
|
||||||
long long alive_count = 0;
|
|
||||||
long long real_alive_count = 0;
|
|
||||||
std::array<long long, 30> params = {};
|
|
||||||
std::array<int, 30> entity_num = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
struct Map;
|
struct Map;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user