Skip to content

Instantly share code, notes, and snippets.

@robfe
Created July 1, 2010 15:18
Show Gist options
  • Save robfe/460096 to your computer and use it in GitHub Desktop.
Save robfe/460096 to your computer and use it in GitHub Desktop.
using(new CodeTimer("connecting")){connect();}
public class CodeTimer : IDisposable
{
private readonly string _message;
private readonly Stopwatch _sw = new Stopwatch();
public CodeTimer(string message)
{
_message = message;
_sw.Start();
}
public void Dispose()
{
_sw.Stop();
Console.Out.WriteLine("{0} took {1} msec", _message, _sw.ElapsedMilliseconds);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment