You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.2 KiB
119 lines
4.2 KiB
using System.Collections.Generic;
|
|
using Sog;
|
|
using Sog.Log;
|
|
|
|
|
|
namespace Battle
|
|
{
|
|
/// <summary>
|
|
/// game服务器统计相关信息的辅助类
|
|
/// </summary>
|
|
public static class BattleServerStat
|
|
{
|
|
private static long m_lastLogTime;
|
|
|
|
public static void Tick(long nowMs)
|
|
{
|
|
ServerStat.Instance.Tick(nowMs);
|
|
|
|
//每分钟记录一次一些信息
|
|
if (nowMs < m_lastLogTime + 60000)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_lastLogTime = nowMs;
|
|
|
|
WriteServerStat();
|
|
}
|
|
|
|
private static void WriteServerStat()
|
|
{
|
|
LogBattleCheckStat();
|
|
}
|
|
|
|
private static void LogBattleCheckStat()
|
|
{
|
|
var checkStat = BattleServerUtils.GetBattleServerData().battleCheckStat;
|
|
|
|
// 1秒的逻辑需要多少毫秒进行校验
|
|
float checkRate = 0.0f;
|
|
if (checkStat.battleLogicTimeMs > 0)
|
|
{
|
|
checkRate = checkStat.battleCheckTimeMs * 1000.0f / checkStat.battleLogicTimeMs;
|
|
}
|
|
|
|
TraceLog.Stat("CheckStat_1Min: battleNum {0} succ {1} max checkTimeMs {2} max mainland {3} logicTime {4:N3} checkTimeMs {5} checkRate {6:N3} arena {7} succ {8}"
|
|
, checkStat.battleNum, checkStat.checkSuccBattleNum
|
|
, checkStat.maxCheckTimeMs, checkStat.maxMainlandId
|
|
, checkStat.battleLogicTimeMs / 1000.0f, checkStat.battleCheckTimeMs
|
|
, checkRate, checkStat.arenaNum, checkStat.checkSuccArenaNum);
|
|
|
|
checkRate = 0.0f;
|
|
if (checkStat.battleLogicTimeMs_total > 0)
|
|
{
|
|
checkRate = checkStat.battleCheckTimeMs_total * 1000.0f / checkStat.battleLogicTimeMs_total;
|
|
}
|
|
|
|
TraceLog.Stat("CheckStat_Total: battleNum {0} succ {1} max checkTimeMs {2} max mainland {3} logicTime {4:N3} checkTimeMs {5} checkRate {6:N3} arena {7} succ {8}"
|
|
, checkStat.battleNum_total, checkStat.checkSuccBattleNum_total
|
|
, checkStat.maxCheckTimeMs_total, checkStat.maxMainlandId_total
|
|
, checkStat.battleLogicTimeMs_total / 1000.0f, checkStat.battleCheckTimeMs_total
|
|
, checkRate, checkStat.arenaNum_total, checkStat.checkSuccArenaNum_total);
|
|
|
|
foreach (var kvp in checkStat.errorCount)
|
|
{
|
|
TraceLog.Stat("CheckStat: error code {0} count {1}", kvp.Key, kvp.Value);
|
|
}
|
|
|
|
foreach (var kvp in checkStat.appVersionFailCount)
|
|
{
|
|
TraceLog.Stat("CheckStat: appVersion {0} fail {1}", AppVersion.ToStringVersion(kvp.Key), kvp.Value);
|
|
}
|
|
|
|
long totalNum = checkStat.totalMainlandNum;
|
|
TraceLog.Stat("MainlandType EnterNum Permillage");
|
|
if(totalNum > 0)
|
|
{
|
|
foreach (var kvp in checkStat.enterMainlandNum)
|
|
{
|
|
TraceLog.Stat("{0,-15}{1,-10} {2,-6}", kvp.Key, kvp.Value, kvp.Value * 1000 / totalNum);
|
|
}
|
|
}
|
|
|
|
TraceLog.Stat("MainlandTotalNum:{0}", totalNum);
|
|
|
|
TraceLog.Stat("ArenaType EnterNum Permillage");
|
|
|
|
totalNum = checkStat.totalArenaNum;
|
|
if(totalNum > 0)
|
|
{
|
|
foreach (var kvp in checkStat.enterArenaNum)
|
|
{
|
|
TraceLog.Stat("{0,-10}{1,-10} {2,-6}", kvp.Key, kvp.Value, kvp.Value * 1000 / totalNum);
|
|
}
|
|
}
|
|
|
|
TraceLog.Stat("ArenaTotalNum:{0}", totalNum);
|
|
|
|
checkStat.battleNum = 0;
|
|
checkStat.checkSuccBattleNum = 0;
|
|
checkStat.maxCheckTimeMs = 0;
|
|
checkStat.maxMainlandId = 0;
|
|
checkStat.battleLogicTimeMs = 0;
|
|
checkStat.battleCheckTimeMs = 0;
|
|
checkStat.arenaNum = 0;
|
|
checkStat.checkSuccArenaNum = 0;
|
|
}
|
|
|
|
public static void AddIDValue(string id, long value, bool clear)
|
|
{
|
|
ServerStat.Instance.AddValue(id, value, clear);
|
|
}
|
|
|
|
public static void SetIDValue(string id, long value, bool clear)
|
|
{
|
|
ServerStat.Instance.SetValue(id, value, clear);
|
|
}
|
|
}
|
|
}
|
|
|