Created
June 7, 2011 04:17
-
-
Save jakcharlton/1011683 to your computer and use it in GitHub Desktop.
A quick and simple timer class to wrap
This file contains 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
using (new TimeIt()) { command.Execute(); } | |
public class TimeIt : IDisposable | |
{ | |
private readonly TextWriter output; | |
private readonly Stopwatch watch; | |
public TimeIt() : this(Console.Out) {} | |
public TimeIt(TextWriter output) | |
{ | |
this.output = output; | |
watch = Stopwatch.StartNew(); | |
} | |
public void Dispose() | |
{ | |
output.WriteLine("Execution took : " + watch.Elapsed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment