欢迎光临散文网 会员登陆 & 注册

C# 简单测试代码运行时间

2021-09-17 16:42 作者:HK4952  | 我要投稿

            //测算运行时间

            Stopwatch st = new Stopwatch();

            st.Restart();   // 停止时间间隔测量,将运行时间重置为零,然后开始测量运行时间

            for (int i = 0; i < 100000000; i++)

            {

                //System.Threading.Thread.Sleep(100);

            }

            MessageBox.Show(st.ElapsedMilliseconds.ToString());     //用时222毫秒

Author:  HK

Date  :   2021-09-16-21:00

Address:SZ  


C# 简单测试代码运行时间的评论 (共 条)

分享到微博请遵守国家法律