Add timing method that returns a value

This commit is contained in:
Jarrod Doyle 2024-08-26 14:03:37 +01:00
parent e213b3ea26
commit 326543c0f6
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 9 additions and 0 deletions

View File

@ -12,4 +12,13 @@ public static class Timing
watch.Stop();
Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}");
}
public static T TimeStage<T>(string stagename, Func<T> action)
{
var watch = Stopwatch.StartNew();
var value = action();
watch.Stop();
Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}");
return value;
}
}