Give PerfTimer the ability to write only slow operations to the log
This is useful to ignore fast operations that just spam the log. The class had to be reworked because it couldn't properly handle cases where all of a node's children where below the threshold. Also changed DoTimed() and RunActivity() to use PerfTimer.
This commit is contained in:
@@ -174,15 +174,10 @@ namespace OpenRA
|
||||
|
||||
public static void DoTimed<T>(this IEnumerable<T> e, Action<T> a, string text, TimeSpan time)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
e.Do(x =>
|
||||
{
|
||||
var t = sw.Elapsed;
|
||||
a(x);
|
||||
var dt = sw.Elapsed - t;
|
||||
if (dt > time)
|
||||
Log.Write("perf", text, x, dt.TotalMilliseconds, Game.LocalTick);
|
||||
using (new PerfTimer("[{0}] {1}: {2}".F(Game.LocalTick, text, x), (int)time.TotalMilliseconds))
|
||||
a(x);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user