How long need a portion of code to be executed ?

Use the Stopwatch object !

using System.Diagnostics;

// ...

Stopwatch myStopWatch = Stopwatch.StartNew();

// some code


Console.WriteLine("{0} ms - {1} ticks", myStopWatch.Elapsed.TotalMilliseconds, myStopWatch.ElapsedTicks);

// ...

About Sam Beauvois

Application Developer, .NET enthusiast since 2004, I'm interested in technology watch, usability, code quality, patterns & practices, UX, ...

1 comment

  1. WP Themes says:

    Amiable fill someone in on and this post helped me alot in my college assignement. Say thank you you as your information.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>