instrument FindUnitsInCircle for perf

This commit is contained in:
Chris Forbes
2010-05-19 20:13:01 +12:00
parent 76bcd7cb26
commit 55a58394e4

View File

@@ -25,6 +25,7 @@ using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Support;
namespace OpenRA namespace OpenRA
{ {
@@ -92,6 +93,8 @@ namespace OpenRA
} }
public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r) public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
{
using (new PerfSample("FindUnitsInCircle"))
{ {
var min = a - new float2(r, r); var min = a - new float2(r, r);
var max = a + new float2(r, r); var max = a + new float2(r, r);
@@ -104,6 +107,7 @@ namespace OpenRA
return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r); return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
} }
}
public static IEnumerable<int2> FindTilesInCircle(this World world, int2 a, int r) public static IEnumerable<int2> FindTilesInCircle(this World world, int2 a, int r)
{ {