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

@@ -66,14 +66,13 @@ namespace OpenRA
{
// PERF: This is a hot path and must run with minimal added overhead, so we enumerate manually
// to allow us to call PerfTickLogger only once per iteration in the normal case.
var perfLogger = new PerfTickLogger();
using (var enumerator = e.GetEnumerator())
{
perfLogger.Start();
var start = PerfTickLogger.GetTimestamp();
while (enumerator.MoveNext())
{
a(enumerator.Current);
perfLogger.LogTickAndRestartTimer(text, enumerator.Current);
start = PerfTickLogger.LogLongTick(start, text, enumerator.Current);
}
}
}