1. 运行时间精准测量
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
//
// 监控用时的中间代码...
//
sw.Stop();
long len = sw.ElapsedMilliseconds;
//2.设置断言,打印输出
//如:重载窗口函数
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
System.Diagnostics.Debug.Assert(this.Width > 200, "width should be larger than 200.");
System.Diagnostics.Debug.WriteLine(this.Size.ToString());
}