コード例 #1
0
        static void TestDicKey(int count = 10000000)
        {
            var type     = typeof(Program);
            var fName    = type.FullName;
            var hashCode = type.GetHashCode();

            var dicString = new Dictionary <string, object>();

            dicString[fName] = null;
            SpeedTest.ConsoleTime("Dictionary<string, object>", count, () =>
            {
                var a = dicString[fName];
            });


            var dicType = new Dictionary <Type, object>();

            dicType[type] = null;
            SpeedTest.ConsoleTime("Dictionary<Type, object>", count, () =>
            {
                var a = dicType[type];
            });


            var dicInt = new Dictionary <int, object>();

            dicInt[hashCode] = null;
            SpeedTest.ConsoleTime("Dictionary<int, object>", count, () =>
            {
                var a = dicInt[hashCode];
            });
        }
コード例 #2
0
        static void TestToList(int count = 100000)
        {
            var dt = Table.Data.User.ToTable();

            for (var i = 0; i < count; i++)
            {
                dt.Rows.Add(1, "xxxxxx", "ffffffffff", 0, 0, "xxxx", 0, DateTime.Now);
            }

            SpeedTest.ConsoleTime("自动赋值", 1, () => { dt.ToList <UserVO>(); });
            SpeedTest.ConsoleTime("手动赋值", 1, () =>
            {
                var lst = new List <UserVO>();
                foreach (DataRow row in dt.Rows)
                {
                    var info = new UserVO
                    {
                        ID         = row["ID"].ConvertType(0),
                        UserName   = row["UserName"].ConvertType(""),
                        PassWord   = row["PassWord"].ConvertType(""),
                        GenderType = row["GenderType"].ConvertType(eumGenderType.Man),
                        LogCount   = row["LoginCount"].ConvertType(0),
                        LoginIP    = row["LoginIP"].ConvertType(""),
                        CreateAt   = row["CreateAt"].ConvertType(DateTime.Now),
                    };
                    lst.Add(info);
                }
            });
        }
コード例 #3
0
 public void TestTime()
 {
     SpeedTest.Initialize();
     SpeedTest.ConsoleTime("context", 100000, () =>
     {
         var context = new Demo.PO.Table();
     });
 }
コード例 #4
0
        public void TestTime()
        {
            SpeedTest.Initialize();
            var ID = Table.Data.User.Desc(o => o.ID).ToEntity().ID;

            Table.Data.User.Where(o => o.ID == ID).Update(new UserVO()
            {
                UserName = "******"
            });

            SpeedTest.ConsoleTime("x1", 1, () =>
            {
                for (var i = 0; i < 1000; i++)
                {
                    Table.Data.Set <UserVO>().Where(o => o.ID == ID).Update(new UserVO()
                    {
                        UserName = "******"
                    });
                }
            });
            SpeedTest.ConsoleTime("x2", 1, () =>
            {
                for (var i = 0; i < 1000; i++)
                {
                    Table.Data.User.Where(o => o.ID == ID).Update(new UserVO()
                    {
                        UserName = "******"
                    });
                }
            });


            //var context = new Table();
            //SpeedTest.ConsoleTime("批量提交", 1, () =>
            //{
            //    for (int i = 0; i < 1000; i++)
            //    {
            //        context.User.Where(o => o.ID == ID).Update(new UserVO() { UserName = "******" });
            //    }
            //    context.SaveChanges();
            //});


            //SpeedTest.ConsoleTime("单次提交", 1, () =>
            //{
            //    for (int i = 0; i < 1000; i++)
            //    {
            //        Table.Data.User.Where(o => o.ID == ID).Update(new UserVO() { UserName = "******" });
            //    }
            //});
        }
コード例 #5
0
        static void TestGetValueCache(int count = 1000000)
        {
            var user         = new UserVO();
            var propertyInfo = user.GetType().GetProperty("UserName");

            SpeedTest.ConsoleTime("手动取值", count, () =>
            {
                var a = user.UserName;
            });
            SpeedTest.ConsoleTime("表达式树取值", count, () =>
            {
                var a = PropertyGetCacheManger.Cache(propertyInfo, user);
            });
            SpeedTest.ConsoleTime("反射取值", count, () =>
            {
                var a = propertyInfo.GetValue(user, null);
            });
        }
コード例 #6
0
        static void TestSetValueCache(int count = 10000000)
        {
            var user         = new UserVO();
            var propertyInfo = user.GetType().GetProperty("UserName");

            SpeedTest.ConsoleTime("手动赋值", count, () =>
            {
                user.UserName = "******";
            });
            SpeedTest.ConsoleTime("表达式树赋值", count, () =>
            {
                PropertySetCacheManger.Cache(propertyInfo, user, "jj");
            });
            SpeedTest.ConsoleTime("反射赋值", count, () =>
            {
                propertyInfo.SetValue(user, "jj", null);
            });
        }
コード例 #7
0
        static void TestTableInstance(int count = 10000)
        {
            var tableType = typeof(Table);

            var type = typeof(TableSet <UserVO>);

            SpeedTest.ConsoleTime("手动创建", count, () =>
            {
                var table = new Table();
            });
            SpeedTest.ConsoleTime("表达式树创建", count, () =>
            {
                var table = (Table)InstanceCacheManger.Cache(tableType);
            });
            SpeedTest.ConsoleTime("反射创建", count, () =>
            {
                var table = (Table)Activator.CreateInstance(tableType);
            });
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: zhangjian0376/Farseer.Net
        static void TestTableInstance(int count = 1000000)
        {
            var table = new Table();
            var type  = typeof(TableSet <UserVO>);

            SpeedTest.ConsoleTime("手动创建", count, () =>
            {
                var User = new TableSet <UserVO>(table, "User");
                //table.Dispose();
            });
            SpeedTest.ConsoleTime("表达式树创建", count, () =>
            {
                var po = (TableSet <UserVO>)CacheManger.CreateInstance(type, table, "User");
                //table.Dispose();
                //Expressions.CreateInstance(type);
            });
            SpeedTest.ConsoleTime("反射创建", count, () =>
            {
                var po = (TableSet <UserVO>)Activator.CreateInstance(type, table, "User");
                //table.Dispose();
            });
        }
コード例 #9
0
        public static void Tests()
        {
            Init();
            AddData();

            var mapData = ConvertHelper.DataTableToDictionary(dt);

            for (int i = 0; i < 5; i++)
            {
                //ConvertDataTable();
                //SpeedTest.ConsoleTime("手动实现转换:DataTable转实体", 1, ConvertDataTable);
                //ExpressionConvertDataTable();
                //SpeedTest.ConsoleTime("表达式树委托:DataTable转实体", 1, ExpressionConvertDataTable);
                //AutoConvertDataTable();
                //SpeedTest.ConsoleTime("动态编译转换:DataTable转实体", 1, AutoConvertDataTable);
                //Context.Data.QuoteExpression.ToList(50000);
                //SpeedTest.ConsoleTime("动态编译转换:DataTable转实体", 50000, () => Context.Data.QuoteExpression.ToList(50000));

                ConvertHelper.ConvertType(0, 0);
                SpeedTest.ConsoleTime("动态编译转换:DataTable转实体", 1000000, () =>
                                      { ConvertHelper.ConvertType(0, 0); });
            }
        }