C#: 获取代码执行时间(精确到毫秒)

C#: 获取代码执行时间(精确到毫秒)

private void Time(int i)
{
   Stopwatch sw = new Stopwatch();
   sw.Start();
   Thread.Sleep(i);
   sw.Stop();
   Console.WriteLine(sw.ElapsedTicks / (decimal)Stopwatch.Frequency * 1000);
}

 

posted @ 2021-02-20 10:48  jasonlai2016  阅读(934)  评论(0编辑  收藏  举报