Skip to content

Instantly share code, notes, and snippets.

@0xorial
Last active March 9, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xorial/4f8054b2d41960a506e8d10643da0c39 to your computer and use it in GitHub Desktop.
Save 0xorial/4f8054b2d41960a506e8d10643da0c39 to your computer and use it in GitHub Desktop.
public class S : IDisposable
{
private static void Log(string s)
{
Console.WriteLine(DateTime.Now + ": " + s);
}
private readonly string _caller;
private readonly System.Diagnostics.Stopwatch _s;
public S(string caller)
{
_s = System.Diagnostics.Stopwatch.StartNew();
_caller = caller;
Log("starting " + caller);
}
public void Dispose()
{
_s.Stop();
Log($"finished {_caller} in {_s.ElapsedMilliseconds} ms");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment