I ran across this link over at DotNetKicks and after reading it I basically smacked myself because I literally could have used this about a week ago on a client project where I was spitting out the time it took to upload a file to a SharePoint document library.

http://www.alteridem.net/2008/01/14/the-stopwatch-class-in-net/

Turns out there is a built in System.Diagnostics.Stopwatch class that is built into the .NET 2.0 framework.  It basically prevents you from creating a start DateTime object, starting some long running code, and doing some DateTime calculations against your original start DateTime object all in a futile attempt to find out how long a process ran.

After looking at the example code from the link above, it doesn't seem like your saving lines of code, but it is a bit easier to use and your only technically creating 1 object, as opposed to 2.  What would be interesting is to check out the MSIL code that gets generated from each example.  Doing so might shed some light onto which methods is more "effective".


Posted in:   Tags:

Comments


February 1. 2010 08:05
Loans in Oregon
Formula for success: Rise early, work hard, strike oil.

http://superpaydayloan.com/state/Oregonhttp://superpaydayloan.com/state/Oregon

Search Blog

Blog Roll

    OPMLDownload OPML file

    Recent Comments

    Banners

    Theme Grabber
    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010 Tony Testa's World