Quick way to measure time taken by a code block or method call or service call

Posted: February 16, 2011 in C#, Performance
Tags: ,

System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
<code block or method call or service call>
timer.Stop();
timer.ElapsedMilliseconds.ToString(); // capture this value using some logging mechanism to check it or you can debug it to see the value

There are many tools available in market to see the time scanning at each method between request to response life cycle.

Advertisements

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