diff --git a/BizHawk.Common/Ranges.cs b/BizHawk.Common/Ranges.cs
index 3527a59442..30523d85b8 100644
--- a/BizHawk.Common/Ranges.cs
+++ b/BizHawk.Common/Ranges.cs
@@ -1,13 +1,11 @@
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-using BizHawk.Common.NumberExtensions;
-
namespace BizHawk.Common
{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ using BizHawk.Common.NumberExtensions;
+
/// semantically similar to , but obviously does no checks at runtime
public struct RangeStruct where T : unmanaged, IComparable
{
diff --git a/BizHawk.Common/SimpleTime.cs b/BizHawk.Common/SimpleTime.cs
index d86e3f33b0..745f7d617d 100644
--- a/BizHawk.Common/SimpleTime.cs
+++ b/BizHawk.Common/SimpleTime.cs
@@ -1,31 +1,27 @@
-#nullable disable
-
-using System;
-using System.Diagnostics;
-
-namespace BizHawk.Common
+namespace BizHawk.Common
{
+ using System;
+ using System.Diagnostics;
+
+ /// Create a new instance of this class in a block, and it will measure the time elapsed until the block finishes executing. Provide a label to print to stdout or provide a callback for custom behaviour.
public class SimpleTime : IDisposable
{
- private readonly Stopwatch _w;
- private readonly Action _f;
+ private readonly Action _callback;
- public SimpleTime(string s)
- : this(t => Console.WriteLine("Elapsed time for {0}: {1}ms", s, t))
+ private readonly Stopwatch _stopwatch = new Stopwatch();
+
+ public SimpleTime(Action callback)
{
+ _callback = callback;
+ _stopwatch.Start();
}
- public SimpleTime(Action f)
- {
- _f = f;
- _w = new Stopwatch();
- _w.Start();
- }
+ public SimpleTime(string label) : this(l => Console.WriteLine($"Elapsed time for {label}: {l} ms")) {}
public void Dispose()
{
- _w.Stop();
- _f((int)_w.ElapsedMilliseconds);
+ _stopwatch.Stop();
+ _callback(_stopwatch.ElapsedMilliseconds);
}
}
}