public string GetStats() { return "PING STATS:" + $"\nPings sent:\t {m_Stats?.TotalPings ?? 0}" + $"\nLatest ping:\t {m_Stats?.LastPing ?? 0} ms" + $"\nAverage ping:\t {m_Stats?.TotalAverage ?? 0:F} ms" + $"\n50-ping Average:\t {m_Stats?.GetRollingAverage() ?? 0:F} ms" + $"\nBest Ping: \t {m_Stats?.BestPing ?? 0} ms" + $"\nWorst Ping:\t {m_Stats?.WorstPing ?? 0} ms" + $"\nPings per second:\t {m_Stats?.PingsPerSecond() ?? 0:F}"; }
void ShowStatsUI() { GUILayout.Label( $"Ping number:\t {m_Stats?.TotalPings ?? 0}" + $"\nLatest ping:\t {m_Stats?.LastPing ?? 0} ms" + $"\nAverage ping:\t {m_Stats?.TotalAverage ?? 0:F} ms" + $"\n50-ping Average:\t {m_Stats?.GetRollingAverage() ?? 0:F} ms" + $"\nBest Ping: \t {m_Stats?.BestPing ?? 0} ms" + $"\nWorst Ping:\t {m_Stats?.WorstPing ?? 0} ms" + $"\nPings per second:\t {m_Stats?.PingsPerSecond()?? 0:F}" + $"\n\nFPS: {(1.0f / Time.smoothDeltaTime):F}" ); }
void UpdateForHeadless() { // Don't do anything if we're waiting for matchmaking if (m_Matchmaker != null) { return; } // Start matchmaking if it was requested via command-line flags if (m_HeadlessShouldMatchmake) { StartNewMatchmakingRequest(); return; } // By the time we get to here, MM has already succeeded or failed or we never needed to start it if (m_LastMatchmakingState == Matchmaker.MatchmakingState.Error) { Debug.Log("Matchmaking failed, aborting headless run and shutting down ping client."); EndProgram(1); } // Start ping client if we need to start it if (m_PingClient == null) { if (m_HeadlessShouldPingServer) { StartNewPingClient(); var pingSeconds = m_HeadlessRunTimeMs / 1000f; Debug.Log($"Pinging remote server for {pingSeconds} seconds..."); m_PingUntil = Time.fixedUnscaledTime + pingSeconds; } else if (m_HeadlessShouldTerminateServer) { TerminateRemoteServer(); EndProgram(0); } } else { // Keep pinging until we run out of time if (Time.fixedUnscaledTime < m_PingUntil) { m_PingClient.RunPingGenerator(); } else { // Dump stats before we dispose of the client Debug.Log($"STATS: Pings sent: {m_Stats.TotalPings}" + $"\nSTATS: Last ping: {m_Stats.LastPing}" + $"\nSTATS: Total Average ping: {m_Stats.TotalAverage}" + $"\nSTATS: Average of last 50 pings: {m_Stats.GetRollingAverage()}" + $"\nSTATS: Pings per second: {m_Stats.PingsPerSecond()}"); if (m_HeadlessShouldTerminateServer) { TerminateRemoteServer(); } Debug.Log("Finished headless mode tasks, shutting down..."); EndProgram(0); } } }