Last active
September 21, 2016 21:14
-
-
Save jonsagara/fcb28b137835eab2e3eb0d2d254e8415 to your computer and use it in GitHub Desktop.
Quick-and-dirty C# profiler. Really, it's just a wrapper for Stopwatch. Replace Console.WriteLine with whatever output makes sense.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QuickProfiler : IDisposable | |
{ | |
private readonly Stopwatch _sw = Stopwatch.StartNew(); | |
private readonly string _name; | |
public QuickProfiler(string name) | |
{ | |
_name = name; | |
} | |
public void Dispose() | |
{ | |
_sw.Stop(); | |
Console.WriteLine($"QuickProfiler: {_name} took {_sw.ElapsedMilliseconds}ms"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Sample output: