PerfTickLogger, reduce overhead of logging long ticks.

This commit is contained in:
Vapre
2022-08-02 17:20:14 +02:00
committed by Matthias Mailänder
parent c095690619
commit edbded8f0a
5 changed files with 51 additions and 42 deletions

View File

@@ -19,21 +19,19 @@ namespace OpenRA.Traits
public static Activity RunActivity(Actor self, Activity act)
{
// PERF: This is a hot path and must run with minimal added overhead.
// If there are no activities we can bail straight away and save ourselves the overhead of setting up the perf logging.
if (act == null)
return act;
var perfLogger = new PerfTickLogger();
perfLogger.Start();
while (act != null)
var start = PerfTickLogger.GetTimestamp();
do
{
var prev = act;
act = act.TickOuter(self);
perfLogger.LogTickAndRestartTimer("Activity", prev);
start = PerfTickLogger.LogLongTick(start, "Activity", prev);
if (act == prev)
break;
}
while (act != null);
return act;
}