Perf debug

This commit is contained in:
Paul Chote
2011-05-12 17:39:34 +12:00
parent 00f0773dc1
commit be79529d9e
6 changed files with 94 additions and 1 deletions

View 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);
}
}
}