2.10.15: PERF report 2 min after the world loaded, then every 5 min, and a final one when quitting; reset per scene
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+14
-4
@@ -18,6 +18,8 @@ namespace MSCO
|
||||
static int frames, gcStart = -1;
|
||||
static double frameSeconds, worstFrame;
|
||||
static float started = -1f;
|
||||
static int level = -1;
|
||||
static int reports;
|
||||
static readonly bool autoLog = Array.IndexOf(Environment.GetCommandLineArgs(), "-msco-perf") >= 0;
|
||||
|
||||
public static void Add(string part, double ms)
|
||||
@@ -30,20 +32,28 @@ namespace MSCO
|
||||
/// <summary>Einmal pro Bild (Update).</summary>
|
||||
public static void Frame(float dt)
|
||||
{
|
||||
if (started < 0f) Reset();
|
||||
// Neue Szene (Menü -> Spiel): neu anfangen, sonst zählt das Laden mit
|
||||
if (started < 0f || Application.loadedLevel != level) { level = Application.loadedLevel; reports = 0; Reset(); }
|
||||
frames++;
|
||||
frameSeconds += dt;
|
||||
if (dt > worstFrame) worstFrame = dt;
|
||||
// Mit -msco-perf alle 30 s, sonst im Spiel alle 5 Minuten ein Bericht in MSCO_Loader.txt - so lässt sich bei
|
||||
// "wenig FPS" nachsehen, ob MSCO, eine Mod oder das Spiel selbst die Zeit braucht
|
||||
float every = autoLog ? 30f : 300f;
|
||||
// Mit -msco-perf alle 30 s, sonst im Spiel nach 2 Minuten und dann alle 5 Minuten ein Bericht in MSCO_Loader.txt -
|
||||
// so lässt sich bei "wenig FPS" nachsehen, ob MSCO, eine Mod oder das Spiel selbst die Zeit braucht
|
||||
float every = autoLog ? 30f : reports == 0 ? 120f : 300f;
|
||||
if ((autoLog || MenuHelper.InGame) && Time.realtimeSinceStartup - started >= every)
|
||||
{
|
||||
Bootstrap.Log(Report());
|
||||
reports++;
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Beim Beenden: was seit dem letzten Bericht gemessen wurde (mindestens 20 s im Spiel).</summary>
|
||||
public static void FinalReport()
|
||||
{
|
||||
if (frames > 0 && MenuHelper.InGame && Time.realtimeSinceStartup - started >= 20f) Bootstrap.Log(Report());
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
totals.Clear();
|
||||
|
||||
Reference in New Issue
Block a user