C#计算程序运行时间

来源:互联网 发布:网络聊天技巧话术 编辑:程序博客网 时间:2024/06/05 20:07
var sw = new Stopwatch();  //使用Stopwatch类计算
            sw.Reset();                //重置测量时间
            sw.Start();                  //开始计算
            for (var i = 0; i < 100; i++)
            {
                ComInput comInput = null;
                var agentW = new AgentW();
                comInput = ComInput.GetComInput();
                comInput.SetPm("field1", Guid.NewGuid().ToString());
                comInput.SetPm("field2", Guid.NewGuid().ToString());
                agentW.Cmd("BLL.DTS.Affairs.Test.Insert", comInput);
            }
            sw.Stop();               //终止计算
            Response.Write(sw.ElapsedMilliseconds + " ms \t\t");//打印时间
原创粉丝点击