Search This Blog

Monday, July 19, 2010

How can we calculate execution time of particular function?

  • Create DateTime dtStart = DateTime.Now;
  • Call the function you want to test.
  • After calling function write DateTime dtEnd = DateTime.Now;
  • Now create TimeSpan object to know the difference between starting time and ending time.
          TimeSpan ts = dtEnd - dtStart;


     Example:

     DateTime dtStart = DateTime.Now;
     functionName(params);
     DateTime dtEnd = DateTime.Now;
     TimeSpan ts = dtEnd - dtStart;

No comments:

Post a Comment