C# 里增加了一个专门用来计时的类,叫 Stopwatch。这样可以简化一些编程,见下例:
class StopWatchTest : IEntryPoint { public void EntryPoint() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); System.Threading.Thread.Sleep(1000); stopwatch.Stop(); long elapsedTimeInMilliSeconds = stopwatch.ElapsedMilliseconds; Console.Out.WriteLine("elapsedTimeInMilliSeconds = {0}", elapsedTimeInMilliSeconds); } }
|
这个类在 System.Diagnostics 命名空间中。
阅读(2467) | 评论(0) | 转发(0) |