C# ASP.Net .Net 单元测试时间

[TestClass]
    public class FacilityTest
    {public FacilityTest()
        {
        }


        [TestInitialize]
        public void InitTestData()
        {
            
        }

        [TestCleanup]
        public void ClearTestData()
        {

        }

        /// <summary>
        /// 添加扣分情况
        /// </summary>
        [TestMethod]
        public void UpdateCameraIsOnLine()
        {

            DateTime beginTime1 = DateTime.Now;
            for (int i = 0; i < 100000; i++) {
                AttributeVerification.DesensitizationData1("13888888888");
            }
            DateTime endTime1 = DateTime.Now;
            double diff1 = ExecDateDiff(beginTime1, endTime1);

            DateTime beginTime2 = DateTime.Now;
            for (int i = 0; i < 100000; i++)
            {
                AttributeVerification.DesensitizationData("13888888888");
} DateTime endTime2 = DateTime.Now; double diff2 = ExecDateDiff(beginTime2, endTime2); Assert.IsTrue(diff1> diff2, "执行失败"); } /// <summary> /// 程序执行时间测试 /// </summary> /// <param name="dateBegin">开始时间</param> /// <param name="dateEnd">结束时间</param> /// <returns>返回(秒)单位,比如: 0.00239秒</returns> public static double ExecDateDiff(DateTime dateBegin, DateTime dateEnd) { TimeSpan ts1 = new TimeSpan(dateBegin.Ticks); TimeSpan ts2 = new TimeSpan(dateEnd.Ticks); TimeSpan ts3 = ts1.Subtract(ts2).Duration(); //你想转的格式 return ts3.TotalMilliseconds; } }

 

[TestClass]    public class FacilityTest    {        protected static readonly ILog _logger = LogManager.GetLogger(typeof(SkyNetTest));

        private IWindsorContainer _container;        private ISkyNetMgeSvr _svr;        private IWorkFormCenterSvr _iWorkFormCenterSvr;        private IRightCheck _auther;        private IAuthorize _authorize;        private LoginResult _lgResult;

        public FacilityTest()        {            if (_container == null)            {                _container = ComponentManager.GetInstance();
                //_container.AddComponent("AppSelfConfigMsg", typeof(IAppSelfConfigMsg), typeof(AppSelfConfigMsg));            }            _authorize = ServiceManager.GetService<IAuthorize>(AccountServiceConst.Component_Authorize, true);            //_auther = (IRightCheck)_container[typeof(IRightCheck)];            //_auther.Active = true;
            _svr = (ISkyNetMgeSvr)_container["SkyNetMgeSvr"];
            //_auther = new AutherUseRightCheck();            //_auther.Login("127.0.0.1", "zprk", "");        }

        [TestInitialize]        public void InitTestData()        {                    }
        [TestCleanup]        public void ClearTestData()        {
        }
        /// <summary>        /// 添加扣分情况        /// </summary>        [TestMethod]        public void UpdateCameraIsOnLine()        {
            DateTime beginTime1 = DateTime.Now;            for (int i = 0; i < 100000; i++) {                AttributeVerification.DesensitizationData1("13880091741");            }            DateTime endTime1 = DateTime.Now;            double diff1 = ExecDateDiff(beginTime1, endTime1);
            DateTime beginTime2 = DateTime.Now;            for (int i = 0; i < 100000; i++)            {                AttributeVerification.DesensitizationData("13880091741");            }            DateTime endTime2 = DateTime.Now;            double diff2 = ExecDateDiff(beginTime2, endTime2);
            Assert.IsTrue(diff1> diff2, "执行失败");        }
        /// <summary>        /// 程序执行时间测试        /// </summary>        /// <param name="dateBegin">开始时间</param>        /// <param name="dateEnd">结束时间</param>        /// <returns>返回(秒)单位,比如: 0.00239秒</returns>        public static double ExecDateDiff(DateTime dateBegin, DateTime dateEnd)        {            TimeSpan ts1 = new TimeSpan(dateBegin.Ticks);            TimeSpan ts2 = new TimeSpan(dateEnd.Ticks);            TimeSpan ts3 = ts1.Subtract(ts2).Duration();            //你想转的格式            return ts3.TotalMilliseconds;        }    }

C# ASP.Net .Net 单元测试时间

上一篇:基于虹软人脸识别,实现RTMP直播推流追踪视频中所有人脸信息(C#)


下一篇:windows10环境下的RabbitMQ安装步骤(图文)