From d4e842e643c1accc5b030a41b2dddfeaec9b1fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 28 Nov 2015 13:49:11 +0100 Subject: [PATCH 1/2] add a benchmark mode --- OpenRA.Game/Game.cs | 8 ++++++++ OpenRA.Game/Support/LaunchArguments.cs | 3 +++ OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs | 14 ++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 61b998c275..9f28d4bc7f 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -45,6 +45,8 @@ namespace OpenRA public static Sound Sound; public static bool HasInputFocus = false; + public static bool BenchmarkMode = false; + public static GlobalChat GlobalChat; public static OrderManager JoinServer(string host, int port, string password, bool recordReplay = true) @@ -493,6 +495,9 @@ namespace OpenRA Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); + if (BenchmarkMode) + Log.Write("cpu", "{0};{1}".F(LocalTick, PerfHistory.Items["tick_time"].LastValue)); + if (isNetTick) orderManager.Tick(); @@ -578,6 +583,9 @@ namespace OpenRA PerfHistory.Items["batches"].Tick(); PerfHistory.Items["render_widgets"].Tick(); PerfHistory.Items["render_flip"].Tick(); + + if (BenchmarkMode) + Log.Write("render", "{0};{1}".F(RenderFrame, PerfHistory.Items["render"].LastValue)); } static void Loop() diff --git a/OpenRA.Game/Support/LaunchArguments.cs b/OpenRA.Game/Support/LaunchArguments.cs index 659fde15d9..6663544bb4 100644 --- a/OpenRA.Game/Support/LaunchArguments.cs +++ b/OpenRA.Game/Support/LaunchArguments.cs @@ -21,6 +21,9 @@ namespace OpenRA [Desc("Automatically start playing the given replay file.")] public string Replay; + [Desc("Dump performance data into cpu.csv and render.csv in the logs folder.")] + public bool Benchmark; + public LaunchArguments(Arguments args) { if (args == null) diff --git a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs index 1408a50686..ef0964e987 100644 --- a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,6 +40,19 @@ namespace OpenRA.Mods.Common.LoadScreens Ui.ResetAll(); Game.Settings.Save(); + if (Launch.Benchmark) + { + Log.AddChannel("cpu", "cpu.csv"); + Log.Write("cpu", "tick;time [ms]"); + + Log.AddChannel("render", "render.csv"); + Log.Write("render", "frame;time [ms]"); + + Console.WriteLine("Saving benchmark data into {0}".F(Path.Combine(Platform.SupportDir, "Logs"))); + + Game.BenchmarkMode = true; + } + // Join a server directly var connect = Launch.GetConnectAddress(); if (!string.IsNullOrEmpty(connect)) From 276c1984fdfe189ed6242dd2985437cf795a546a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 5 Dec 2015 08:02:48 +0100 Subject: [PATCH 2/2] document graphic settings interesting for benchmarking --- OpenRA.Game/Settings.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index d8efb14788..507c85e82b 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -96,13 +96,25 @@ namespace OpenRA public class GraphicSettings { public string Renderer = "Default"; + + [Desc("This can be set to Windowed, Fullscreen or PseudoFullscreen.")] public WindowMode Mode = WindowMode.PseudoFullscreen; + + [Desc("Screen resolution in fullscreen mode.")] public int2 FullscreenSize = new int2(0, 0); + + [Desc("Screen resolution in windowed mode.")] public int2 WindowedSize = new int2(1024, 768); + public bool HardwareCursors = true; + public bool PixelDouble = false; public bool CursorDouble = false; + + [Desc("Add a frame rate limiter. It is recommended to not disable this.")] public bool CapFramerate = true; + + [Desc("At which frames per second to cap the framerate.")] public int MaxFramerate = 60; public int BatchSize = 8192;