Posted: 5/24/2010
How can we calculate the execution time of each functions/methods in any project so that we should know which funtion is take so much time and we need to work on that?
Is there any prebuild method or property so that we can calculate the execution time?
If you have knowledge of Data Structures (which is usually course in Computer Sciences field), you may have imagination of how to calculate execution time.
Anyway, you can try something like this:
1. Create DateTime dtStart = DateTime.Now;
2. Call the function you want to test
3. After function call line, add DateTime dtEnd = DateTime.Now
At last, create TimeSpan ts = dtEnd - dtStart
Example:
DateTime dtStart = DateTime.Now;
functionName(params);
DateTime dtEnd = DateTime.Now;
TimeSpan ts = dtEnd - dtStart;
// you have the time in the ts value so play with it :).
Regards,Hajan
Posted: 5/25/2010
Thankx for the suggestion for this logic.
Posted: 5/26/2010
Go with profilers. There are many, I will suggest to go with ANTS Performance Profiler™ and dotTrace