2024-08-26 12:22:29 +00:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
namespace KeepersCompound.TMV;
|
|
|
|
|
|
|
|
public static class Timing
|
|
|
|
{
|
|
|
|
public static void TimeStage(string stagename, Action action)
|
|
|
|
{
|
|
|
|
var watch = Stopwatch.StartNew();
|
|
|
|
action();
|
|
|
|
watch.Stop();
|
|
|
|
Godot.GD.Print($"[{stagename}]: {watch.Elapsed:g}");
|
|
|
|
}
|
2024-08-26 13:03:37 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2024-08-26 12:22:29 +00:00
|
|
|
}
|