- DateTime beforDT = System.DateTime.Now;
-
-
-
- DateTime afterDT = System.DateTime.Now;
- TimeSpan ts = afterDT.Subtract(beforDT);
- Console.WriteLine("DateTime总共花费{0}ms.", ts.TotalMilliseconds);
- Stopwatch sw = new Stopwatch();
- sw.Start();
-
-
-
- sw.Stop();
- TimeSpan ts2 = sw.Elapsed;
- Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds);
C#之时间统计
原文:http://www.cnblogs.com/huangshiyu13/p/5645494.html