Sometims we want to know how fast our program running,
I found two methods on stack overflow.
I found two methods on stack overflow.
DateTime dt = DateTime.Now; for (.......) { } TimeSpan ts = DateTime.Now - dt; Console.WriteLine("total runtime: " + ts.ElapsedMilliseconds.ToString() + "ms"); or (according to MSDN) if you need better resolution Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); for (.......) { } stopWatch.Stop(); Console.WriteLine("total runtime: " + stopWatch.ElapsedMilliseconds.ToString() + "ms");
留言
張貼留言