Skip to content

Instantly share code, notes, and snippets.

@brendanmckenzie
Created July 31, 2017 00:40
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 brendanmckenzie/48da2d830c55778f9d2623d7c1c3e52a to your computer and use it in GitHub Desktop.
Save brendanmckenzie/48da2d830c55778f9d2623d7c1c3e52a to your computer and use it in GitHub Desktop.
internal sealed class BasicProfiler : IDisposable
{
readonly string _key;
readonly System.Diagnostics.Stopwatch _stopwatch;
public BasicProfiler(string key)
{
_key = key;
_stopwatch = new System.Diagnostics.Stopwatch();
_stopwatch.Start();
System.Diagnostics.Debug.WriteLine($"Started profiling: {key}");
}
public void Dispose()
{
_stopwatch.Stop();
System.Diagnostics.Debug.WriteLine($"Stopped profiling: {_key} -- {_stopwatch.ElapsedMilliseconds:N0}ms");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment