System.Diagnostics.Stopwatch watch = new Stopwatch();
watch.Start();
//init();计算耗时的方法
watch.Stop();
var mSeconds=watch.ElapsedMilliseconds;
MessageBox.Show("耗时:"+mSeconds.ToString());
05-23 17:40