This blog is moved to
http://amalhashim.wordpress.com

Monday, August 11, 2008

Measuring Execution Time via Code

Hi Guys,

Inorder to measure the execution time in C# you can use the following statements

DateTime startTime = DateTime.Now;
Thread.Sleep(1000);
DateTime endTime = DateTime.Now;
TimeSpan time = endTime - startTime;
Console.WriteLine("Elapsed time {0}", time);


In java the same thing can be achieved using the following statements

long startTime = System.currentTimeMillis();
Thread.Sleep(1000);
long endTime = System.currentTimeMillis();
System.out.println("Connecting MDK method: " + (endTime - startTime)); // print execution time


Thanks,
A.M.A.L

No comments: