Time Difference Calculations

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am interested in finding out the time it takes to complete a certain section of my source code
How do i determine the time difference between the beginning of a process and its end. I need to get the result in Minutes and then second, like e.g. 3 minutes 45 seconds
Any suggestions for a fast solution to this
Thanks in Advance
 
DateTime startTime = DateTime.Now;

... do stuff ...

TimeSpan elapsed = DateTime.Now - startTime;

string nicePrettyString = elapsed.ToString(); // ##:##:##


Keep in mind that the granularity of the system clock will affect the
"exactness" of your time differences.

-Chris



I am interested in finding out the time it takes to complete a certain
section of my source code.
How do i determine the time difference between the beginning of a process
and its end. I need to get the result in Minutes and then second, like e.g.
3 minutes 45 seconds.
Any suggestions for a fast solution to this.
Thanks in Advance
 
Back
Top