Skip to content

Instantly share code, notes, and snippets.

@jakcharlton
Created June 7, 2011 04:17
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 jakcharlton/1011683 to your computer and use it in GitHub Desktop.
Save jakcharlton/1011683 to your computer and use it in GitHub Desktop.
A quick and simple timer class to wrap
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