Perf debug
This commit is contained in:
@@ -34,9 +34,11 @@ namespace OpenRA.GameRules
|
||||
public class DebugSettings
|
||||
{
|
||||
public bool BotDebug = false;
|
||||
public bool PerfText = false;
|
||||
public bool PerfGraph = false;
|
||||
public float LongTickThreshold = 0.001f;
|
||||
public bool SanityCheckUnsyncedCode = false;
|
||||
public int Samples = 25;
|
||||
}
|
||||
|
||||
public class GraphicSettings
|
||||
|
||||
@@ -79,6 +79,20 @@ namespace OpenRA.Support
|
||||
}
|
||||
}
|
||||
|
||||
public double Average(int count)
|
||||
{
|
||||
int i = 0;
|
||||
int n = head;
|
||||
double sum = 0;
|
||||
while (i < count && n != tail)
|
||||
{
|
||||
if (--n < 0) n = samples.Length - 1;
|
||||
sum += samples[n];
|
||||
i++;
|
||||
}
|
||||
return sum / i;
|
||||
}
|
||||
|
||||
public double LastValue
|
||||
{
|
||||
get
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<Compile Include="Widgets\CncMusicPlayerLogic.cs" />
|
||||
<Compile Include="CncColorPickerPaletteModifier.cs" />
|
||||
<Compile Include="Widgets\CncModBrowserLogic.cs" />
|
||||
<Compile Include="Widgets\CncPerfDebugLogic.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
34
OpenRA.Mods.Cnc/Widgets/CncPerfDebugLogic.cs
Normal file
34
OpenRA.Mods.Cnc/Widgets/CncPerfDebugLogic.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
public class CncPerfDebugLogic : IWidgetDelegate
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public CncPerfDebugLogic([ObjectCreator.Param] Widget widget)
|
||||
{
|
||||
// Performance info
|
||||
var perfRoot = widget.GetWidget("PERFORMANCE_INFO");
|
||||
perfRoot.GetWidget("PERF_GRAPH").IsVisible = () => Game.Settings.Debug.PerfGraph;
|
||||
var text = perfRoot.GetWidget<LabelWidget>("PERF_TEXT");
|
||||
text.IsVisible = () => Game.Settings.Debug.PerfText;
|
||||
text.GetText = () =>
|
||||
"Tick {0} @ {1:F1} ms\nRender {2} @ {3:F1} ms\nBatches: {4}".F(
|
||||
Game.LocalTick, PerfHistory.items["tick_time"].Average(Game.Settings.Debug.Samples),
|
||||
Game.RenderFrame, PerfHistory.items["render"].Average(Game.Settings.Debug.Samples),
|
||||
PerfHistory.items["batches"].LastValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,3 +128,20 @@ Container@INGAME_ROOT:
|
||||
Width: 760
|
||||
Height: 30
|
||||
UseContrast: yes
|
||||
Container@PERFORMANCE_INFO:
|
||||
Id:PERFORMANCE_INFO
|
||||
Delegate:CncPerfDebugLogic
|
||||
Children:
|
||||
Label@PERF_TEXT:
|
||||
Id:PERF_TEXT
|
||||
X:10
|
||||
Y:45
|
||||
Width:170
|
||||
Height:40
|
||||
Contrast:true
|
||||
PerfGraph@GRAPH:
|
||||
Id:PERF_GRAPH
|
||||
X:10
|
||||
Y:WINDOW_BOTTOM-HEIGHT-10
|
||||
Width:200
|
||||
Height:200
|
||||
@@ -157,3 +157,28 @@ Container@MENU_BACKGROUND:
|
||||
Width:140
|
||||
Height:35
|
||||
Text:Back
|
||||
Container@PERFORMANCE_INFO:
|
||||
Id:PERFORMANCE_INFO
|
||||
Delegate:CncPerfDebugLogic
|
||||
Children:
|
||||
Label@PERF_TEXT:
|
||||
Id:PERF_TEXT
|
||||
X:40
|
||||
Y:40
|
||||
Width:170
|
||||
Height:40
|
||||
Contrast:true
|
||||
VAlign:Top
|
||||
Background@GRAPH_BG:
|
||||
Id:PERF_GRAPH
|
||||
X:WINDOW_RIGHT-WIDTH-31
|
||||
Y:31
|
||||
Width:220
|
||||
Height:220
|
||||
Background:panel-black
|
||||
Children:
|
||||
PerfGraph@GRAPH:
|
||||
X:10
|
||||
Y:10
|
||||
Width:200
|
||||
Height:200
|
||||
Reference in New Issue
Block a user