Script Timer

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

Im new to csharp. I need to time the execute time of a script and
output the time as a string.

can someone help me write this function


time1 //at the beginning of the script

..
..
..

time2 //at the end of the script
string exeTime = time2 - time1


thanks
 
Aaron said:
I need to time the execute time of a script and
output the time as a string.

DateTime dtStart = DateTime.Now;

// Wait three seconds
while ((DateTime.Now - dtStart).Seconds < 3) { }

DateTime dtEnd = DateTime.Now;

Console.WriteLine("Time taken: {0}", dtEnd - dtStart);

P.
 
Back
Top