debug (timing) spam, and perf fixed on SupportPower

Build timing (un)hacked by chrisf
This commit is contained in:
Bob
2010-05-16 17:27:19 +12:00
committed by Chris Forbes
parent de9ec12c8c
commit 7deefc5246
8 changed files with 136 additions and 23 deletions

View File

@@ -23,6 +23,7 @@ using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Traits;
using OpenRA.Support;
namespace OpenRA
{
@@ -92,5 +93,19 @@ namespace OpenRA
var xs = ts.ToArray();
return xs[r.Next(xs.Length)];
}
public static void DoTimed<T>( this IEnumerable<T> e, Action<T> a, string text, double time )
{
var sw = new Stopwatch();
e.Do( x =>
{
var t = sw.ElapsedTime();
a( x );
var dt = sw.ElapsedTime() - t;
if( dt > time )
Log.Write( text, x, dt*1000 );
} );
}
}
}