System.Diagnostics.Stopwatch

http://blog.csdn.net/sky_zt/article/details/5950932

#if DEBUG
        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
        sw.Start();
#endif

/////////////////////==============中间各种程序====================//////////////

#if DEBUG
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        string elapsedTime = String.Format(fac + ":{0:00}:{1:00}:{2:00}.{3:00}<br />", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
        //Response.Write(elapsedTime);
#endif

原文地址:https://www.cnblogs.com/gerryge/p/2417976.html