Measure Execution Time taken by your code.

To measure an execution time taken by your code, just use the below piece of code at appropriate place in your code block.

using System.Diagnostics;

public static void Main(string[] args)

{

Console.WriteLine(“In Main“);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
//Your Code will go here
stopwatch.Stop();
var timeSpan = stopwatch.Elapsed;
var executionTimeTaken=String.Format(“{0:00}:{1:00}:{2:00}.{3:00}”,timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds / 10);
Console.WriteLine(executionTimeTaken);
}

Thanks,
Md. jawed

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s