more perf diagnostics

This commit is contained in:
Chris Forbes
2009-11-05 23:01:03 +13:00
parent df4b144df4
commit 64a6b34d93
3 changed files with 29 additions and 3 deletions

View File

@@ -145,6 +145,10 @@ namespace OpenRa.Game
public static double RenderTime = 0.0;
public static double TickTime = 0.0;
public static double OreTime = 0.0;
public static double PathToPathTime = 0.0;
public static double NormalPathTime = 0.0;
public static int PathToPathCount = 0;
public static int NormalPathCount = 0;
public static Stopwatch sw;
@@ -155,6 +159,10 @@ namespace OpenRa.Game
if( dt >= timestep )
{
sw.Reset();
PathToPathTime = 0;
NormalPathTime = 0;
PathToPathCount = 0;
NormalPathCount = 0;
lastTime += timestep;
if( orderManager.Tick() )

View File

@@ -99,12 +99,17 @@ namespace OpenRa.Game.Graphics
lineRenderer.Flush();
renderer.DrawText(string.Format("RenderFrame {0} ({2:F1} ms)\nTick {1} ({3:F1} ms)\nOre ({4:F1} ms)\n$ {5}",
renderer.DrawText(string.Format("RenderFrame {0} ({2:F1} ms)\nTick {1} ({3:F1} ms)\nOre ({4:F1} ms)\nNormal Pathing ({5:F1} ms\t[{9} paths])\nPathToPath ({6:F1}\t[{8} paths])\n$ {7}",
Game.RenderFrame, Game.orderManager.FrameNumber,
Game.RenderTime * 1000,
Game.TickTime * 1000,
Game.OreTime * 1000,
Game.LocalPlayer.Cash), new int2(5, 5), Color.White);
Game.NormalPathTime * 1000,
Game.PathToPathTime * 1000,
Game.LocalPlayer.Cash,
Game.PathToPathCount,
Game.NormalPathCount
), new int2(5, 5), Color.White);
}
void DrawSelectionBox(Actor selectedUnit, Color c, bool drawHealthBar)

View File

@@ -28,7 +28,16 @@ namespace OpenRa.Game
public List<int2> FindUnitPath(int2 src, int2 dest, UnitMovementType umt)
{
return FindUnitPath(src, DefaultEstimator(dest), umt);
var sw = new Stopwatch();
/*if (passableCost[(int)umt][dest.X, dest.Y] == double.PositiveInfinity)
return new List<int2>();
if (!Game.BuildingInfluence.CanMoveHere(dest))
return new List<int2>();*/
var result = FindUnitPath(src, DefaultEstimator(dest), umt);
Game.NormalPathTime += sw.ElapsedTime();
Game.NormalPathCount++;
return result;
}
public List<int2> FindUnitPathToRange(int2 src, int2 dest, UnitMovementType umt, int range)
@@ -43,6 +52,8 @@ namespace OpenRa.Game
public List<int2> FindPathToPath( int2 from, List<int2> path, UnitMovementType umt )
{
var sw = new Stopwatch();
var cellInfo = InitCellInfo();
var queue = new PriorityQueue<PathDistance>();
var estimator = DefaultEstimator( from );
@@ -63,6 +74,8 @@ namespace OpenRa.Game
}
var ret = FindPath( cellInfo, queue, estimator, umt, true );
ret.Reverse();
Game.PathToPathTime += sw.ElapsedTime();
Game.PathToPathCount++;
return ret;
}