C# 测量程序运行时间
using System.Diagnostics; Stopwatch watch = new Stopwatch(); watch.Start(); /* 需要测量运行时间的程序 */ watch.Stop(); this.BeginInvoke(updateTxt, " (耗时" + (watch.ElapsedMilliseconds / 1000.0) + " s)\r\n", Color.Red);
using System.Diagnostics; Stopwatch watch = new Stopwatch(); watch.Start(); /* 需要测量运行时间的程序 */ watch.Stop(); this.BeginInvoke(updateTxt, " (耗时" + (watch.ElapsedMilliseconds / 1000.0) + " s)\r\n", Color.Red);