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:
Pavlos Touboulidis
2014-05-21 17:18:53 +03:00
parent ad2ee2e75f
commit df0d1360dd
4 changed files with 56 additions and 52 deletions

View File

@@ -82,11 +82,8 @@ namespace OpenRA.Traits
{
var prev = act;
var sw = Stopwatch.StartNew();
act = act.Tick(self);
var dt = sw.Elapsed;
if (dt > Game.Settings.Debug.LongTickThreshold)
Log.Write("perf", "[{2}] Activity: {0} ({1:0.000} ms)", prev, dt.TotalMilliseconds, Game.LocalTick);
using (new PerfTimer("[{0}] Activity: {1}".F(Game.LocalTick, prev), (int)Game.Settings.Debug.LongTickThreshold.TotalMilliseconds))
act = act.Tick(self);
if (prev == act)
break;