Friday, May 25, 2012

Asp.Net Performance Tuning


While designing larger and complex web sites, performance tuning is one of the key areas of consideration. Ignoring performance issues earlier will lead to large problems later when the page takes more time to load or when the load on the page (Number of users accessing the page simultaneously) is large.

Performance testing can be done with a set of tools which are available in the market, in fact there is a free tool Web Capacity Analysis Tool (WCAT) which can be integrated with IIS to test the load on the web server, but using these tools require a lot of time to be invested in configuring these tools, a few of the tools also cost a few bucks.

We shall see on how to measure the performance of a function or a code block using a couple of built in classes in .Net

Environment Class
The Environment Class helps us to measure the time elapsed to execute a code in Ticks.

Usage
int startTime, endTime;
startTime = Environment.TickCount;
    //Code to be Evaluated Goes Here.
endTime = Environment.TickCount;
endTime - startTime – Gives the time taken to execute the code in Milliseconds.

To know more on how to use this class refers the post Measure Execution time using Environment class


Stopwatch Class
The Stopwatch Class helps us to measure the time elapsed to execute a code in Milliseconds.

Usage
Stopwatch
 timer = new Stopwatch();
timer.Start();
    
//Code to be Evaluated Goes Here.
timer.Stop();
timer.ElapsedMilliseconds.ToString()
 – Gives the time taken to execute the code in Milliseconds.

To know more on how to use this class refers the post Measure Execution time using Stopwatch class

That’s it we have seen how the 2 simple classes Environment and Stopwatch to measure the performance of .Net code

Search Flipkart Products:
Flipkart.com

1 comment:

LOL Boost said...

Excellent certainly! Many thanks with this!

Buy elo boost


FUT 14 Coins