From 326543c0f6d28460341778674927e9c1b884c72f Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Mon, 26 Aug 2024 14:03:37 +0100 Subject: [PATCH] Add timing method that returns a value --- project/code/TMV/Timing.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/project/code/TMV/Timing.cs b/project/code/TMV/Timing.cs index 8143b14..4cc1e69 100644 --- a/project/code/TMV/Timing.cs +++ b/project/code/TMV/Timing.cs @@ -12,4 +12,13 @@ public static class Timing watch.Stop(); Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}"); } + + public static T TimeStage(string stagename, Func action) + { + var watch = Stopwatch.StartNew(); + var value = action(); + watch.Stop(); + Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}"); + return value; + } } \ No newline at end of file