diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 548d4a17..68834991 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -11,6 +11,7 @@ #include "playermgr.h" #include "httpproxy.h" #include "glmhelper.h" +#include "perf.h" AndroidAgent::AndroidAgent() { @@ -77,6 +78,7 @@ behaviac::EBTStatus AndroidAgent::CoLogin() a8::XPrintf("data:%s\n", {rsp_obj->ToJsonStr()}); #endif if (ok) { + ++Perf::Instance()->login_ok_times; std::string account_id = rsp_obj->At("account_id")->AsXValue().GetString(); std::string session_id = rsp_obj->At("session_id")->AsXValue().GetString(); auto url_params = a8::MutableXObject::CreateObject(); @@ -96,9 +98,11 @@ behaviac::EBTStatus AndroidAgent::CoLogin() a8::XPrintf("data:%s\n", {rsp_obj->ToJsonStr()}); #endif if (ok) { + ++Perf::Instance()->enter_ok_times; context->login_ok = true; } else { context->login_ok = false; + ++Perf::Instance()->enter_fail_times; } }, "https://game2006api-test.kingsome.cn/webapp/index.php", @@ -106,6 +110,7 @@ behaviac::EBTStatus AndroidAgent::CoLogin() ); } else { context->login_ok = false; + ++Perf::Instance()->login_fail_times; } }, "https://login-test.kingsome.cn/webapp/index.php", @@ -172,6 +177,11 @@ behaviac::EBTStatus AndroidAgent::CoConnectBattleServer() if (context->pending) { return behaviac::BT_RUNNING; } + if (context->connect_ok) { + ++Perf::Instance()->connect_ok_times; + } else { + ++Perf::Instance()->connect_fail_times; + } return context->connect_ok ? behaviac::BT_SUCCESS : behaviac::BT_FAILURE; }; return StartCoroutine(co); @@ -226,9 +236,11 @@ behaviac::EBTStatus AndroidAgent::CoUpdateGame() curr_dir_ = glm::vec3(0.0f, 0.0f, 1.0f); GlmHelper::RotateY(curr_dir_, a8::RandAngle()); last_dir_tick_ = a8::XGetTickCount(); + ++Perf::Instance()->chg_dir_times; } if (a8::XGetTickCount() - last_send_tick_ > 80) { last_send_tick_ = a8::XGetTickCount(); + ++Perf::Instance()->send_move_times; { cs::CMMove msg; ToPb(curr_dir_, msg.mutable_move_dir()); diff --git a/server/robotserver/app.cc b/server/robotserver/app.cc index 9afead42..0ecc7c68 100644 --- a/server/robotserver/app.cc +++ b/server/robotserver/app.cc @@ -14,6 +14,7 @@ #include "tracemgr.h" #include "iomgr.h" #include "GGListener.h" +#include "perf.h" #include "mt/MetaMgr.h" @@ -23,6 +24,7 @@ void App::Init() TraceMgr::Instance()->Init("robotserver2006"); #endif HandlerMgr::Instance()->Init(); + Perf::Instance()->Init(); f8::BtMgr::Instance()->Init("exported"); #ifdef MYDEBUG1 f8::BtMgr::Instance()->SetLogging(true); @@ -41,6 +43,7 @@ void App::UnInit() HttpProxy::Instance()->UnInit(); f8::BtMgr::Instance()->UnInit(); IoMgr::Instance()->UnInit(); + Perf::Instance()->UnInit(); HandlerMgr::Instance()->UnInit(); #ifdef MYDEBUG TraceMgr::Instance()->UnInit(); diff --git a/server/robotserver/perf.cc b/server/robotserver/perf.cc index 1dfe89ff..8bd89f3b 100644 --- a/server/robotserver/perf.cc +++ b/server/robotserver/perf.cc @@ -25,18 +25,15 @@ void Perf::UnInit() void Perf::Output() { f8::UdpLog::Instance()->Info - ("perf entity:%d buff:%d bt_co:%d agent:%d c_w_c:%d c_w:%d o_w_c:%d o_w:%d e_w_c:%d e_c:%d e_h:%d", + ("perf login_ok:%d login_fail:%d enter_ok:%d enter_fail:%d connect_ok:%d connect_fail:%d send_move:%d", { - entity_num, - buff_num, - bt_co_num, - agent_num, - c_wptr_chunk_num, - c_wptr_num, - o_wptr_chunk_num, - o_wptr_num, - e_wptr_chunk_num, - e_wptr_num, - event_handler_num + login_ok_times, + login_fail_times, + enter_ok_times, + enter_fail_times, + connect_ok_times, + connect_fail_times, + chg_dir_times, + send_move_times }); } diff --git a/server/robotserver/perf.h b/server/robotserver/perf.h index dfb7ebc9..8b821717 100644 --- a/server/robotserver/perf.h +++ b/server/robotserver/perf.h @@ -13,18 +13,14 @@ private: void Init(); void UnInit(); - long long entity_num = 0; - long long buff_num = 0; - long long bt_co_num = 0; - long long agent_num = 0; - long long c_wptr_chunk_num = 0; - long long c_wptr_num = 0; - long long o_wptr_chunk_num = 0; - long long o_wptr_num = 0; - long long e_wptr_chunk_num = 0; - long long e_wptr_num = 0; - long long event_handler_num = 0; - int traversing_cell_creature_count = 0; + long long login_ok_times = 0; + long long login_fail_times = 0; + long long enter_ok_times = 0; + long long enter_fail_times = 0; + long long connect_ok_times = 0; + long long connect_fail_times = 0; + long long chg_dir_times = 0; + long long send_move_times = 0; private: void Output(); diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index e0ffd300..a01f3e42 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -18,16 +18,6 @@ void PlayerMgr::Init() { -#if 0 - for (int i = 1; i <= 300; ++i) { - int idx = i; - std::string account_id = a8::Format("6513_2006_%d", {idx}); - auto hum = std::make_shared(); - hum->Init(idx, account_id); - account_id_hash_[hum->GetAccountId()] = hum; - socket_id_hash_[hum->GetSocketId()] = hum; - } -#endif int count = 0; f8::Timer::Instance()->SetInterval (