zoukankan      html  css  js  c++  java
  • 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;        }    }

  • 相关阅读:
    DEDECMS里面DEDE函数解析
    dede数据库类使用方法 $dsql
    DEDE数据库语句 DEDESQL命令批量替换 SQL执行语句
    织梦DedeCms网站更换域名后文章图片路径批量修改
    DSP using MATLAB 示例 Example3.12
    DSP using MATLAB 示例 Example3.11
    DSP using MATLAB 示例 Example3.10
    DSP using MATLAB 示例Example3.9
    DSP using MATLAB 示例Example3.8
    DSP using MATLAB 示例Example3.7
  • 原文地址:https://www.cnblogs.com/xiaoruilin/p/14791147.html
Copyright © 2011-2022 走看看