Exemplo n.º 1
0
        protected override void OnHandler(ParameterHandlerInfo info)
        {
            Core.Log.Warning("Starting Serializer TEST");

            if (info.Arguments?.Contains("/complex") == true)
            {
                var file       = "c:\\temp\\complex.test.nbin.gz";
                var serializer = SerializerManager.GetByFileName(file);

                AssemblyResolverManager.RegisterDomain(new[] { @"C:\AGSW_GIT\Travel\src\Flights\Engines\Services\Agsw.Travel.Flights.Engines.Service\bin\Release\netcoreapp2.2" });
                //AssemblyResolverManager.RegisterDomain(new[] { @"C:\Repo\AgswGit\Travel\src\Flights\Engines\Services\Agsw.Travel.Flights.Engines.Service\bin\Release\netcoreapp2.2" });

                object value = null;
                try
                {
                    value = serializer.DeserializeFromFile <object>(file);
                    //value = rMsg.Body.GetValue();
                }
                catch (DeserializerException exGO)
                {
                    var jsonSerializer = new JsonTextSerializer {
                        Indent = true
                    };
                    jsonSerializer.SerializeToFile(exGO.Value, "c:\\temp\\complexObject-GenericObject.json");

                    var val = exGO.Value["Products"][5];
                }

                RunTestEx(value, 500, null);
                //GC.Collect();
                //GC.WaitForFullGCComplete();
                //RunTestEx(value, 200, new GZipCompressor());
                //GC.Collect();
                //GC.WaitForFullGCComplete();
                //RunTestEx(value, 200, new DeflateCompressor());

                return;
            }

            var sTest = new STest
            {
                FirstName = "Daniel",
                LastName  = "Redondo",
                Age       = 33,
                value     = 166
            };

            var collection = new List <List <STest> >();

            for (var i = 0; i <= 10; i++)
            {
                var colSTest = new List <STest>
                {
                    sTest, sTest, sTest, sTest, sTest, sTest,
                    sTest, sTest, sTest, sTest, sTest, sTest,
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 0, Age = 1, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 1, Age = 2, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 2, Age = 3, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 3, Age = 4, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 4, Age = 5, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 5, Age = 6, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 6, Age = 7, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 7, Age = 8, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 8, Age = 9, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 9, Age = 10, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 10, Age = 11
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 11, Age = 12
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 12, Age = 13
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 13, Age = 14
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 14, Age = 15
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 15, Age = 16
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 16, Age = 17
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 17, Age = 18
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 18, Age = 19
                    },
                    //new STest2 { FirstName = "Person" , LastName = "Person" + i + "." + i+19, Age = 20, New = "This is a test" }
                };
                collection.Add(colSTest);
            }

            var lt = new List <STest>
            {
                new STest {
                    FirstName = "Name1", LastName = "LName1", Age = 11
                },
                //new STest2 { FirstName = "Name2" , LastName = "LName2", Age = 20, New = "This is a test" }
            };

            var lt2 = new List <Test3>
            {
                new Test3 {
                    Values = new List <int> {
                        2, 3, 4, 5
                    }
                },
                new Test3 {
                    Values = new List <int> {
                        10, 11, 12, 13
                    }
                }
            };

            var dct = new Dictionary <string, int>
            {
                ["Value1"] = 1,
                ["Value2"] = 2,
                ["Value3"] = 3,
            };

            var colClone = collection[0].DeepClone();
            var clone    = collection.DeepClone();



            if (info.Arguments?.Contains("/parallel") == true)
            {
                RunSingleTest(collection[0], 2, false);
                Core.Log.InfoBasic("Press ENTER to Start:");
                Console.ReadLine();
                Task.WaitAll(
                    Enumerable.Range(0, 8).Select(i => Task.Run(() => RunSingleTest(collection[0], 200_000, false))).ToArray()
                    );
                Console.ReadLine();
                return;
            }

            RunTest(collection[0], 200_000, false);
        }
Exemplo n.º 2
0
        protected override void OnHandler(ParameterHandlerInfo info)
        {
            Core.Log.Warning("Starting Serializer TEST");

            //
            //TWCore.Reflection.AssemblyResolverManager.RegisterDomain(new[] { @"C:\AGSW_GIT\Travel\build\Agsw\Engines\Offer\Service" });
            ////TWCore.Reflection.AssemblyResolverManager.GetAssemblyResolver().app
            //var sObject = SerializedObject.FromFileAsync("c:\\temp\\test.sobj").WaitAndResults();
            //var sObjectValue = sObject.GetValue();
            //RunTest(sObjectValue, 500, false);
            //RunTest(sObjectValue, 500, true);
            //

            var sTest = new STest
            {
                FirstName = "Daniel",
                LastName  = "Redondo",
                Age       = 33
            };

            var collection = new List <List <STest> >();

            for (var i = 0; i <= 10000; i++)
            {
                var colSTest = new List <STest>
                {
                    sTest, sTest, sTest, sTest, sTest, sTest,
                    sTest, sTest, sTest, sTest, sTest, sTest,
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 0, Age = 1, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 1, Age = 2, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 2, Age = 3, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 3, Age = 4, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 4, Age = 5, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 5, Age = 6, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 6, Age = 7, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 7, Age = 8, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 8, Age = 9, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 9, Age = 10, Brother = sTest
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 10, Age = 11
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 11, Age = 12
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 12, Age = 13
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 13, Age = 14
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 14, Age = 15
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 15, Age = 16
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 16, Age = 17
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 17, Age = 18
                    },
                    new STest {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 18, Age = 19
                    },
                    new STest2 {
                        FirstName = "Person", LastName = "Person" + i + "." + i + 19, Age = 20, New = "This is a test"
                    }
                };
                collection.Add(colSTest);
            }

            var lt = new List <STest>
            {
                new STest {
                    FirstName = "Name1", LastName = "LName1", Age = 11
                },
                new STest2 {
                    FirstName = "Name2", LastName = "LName2", Age = 20, New = "This is a test"
                }
            };

            var lt2 = new List <Test3>
            {
                new Test3 {
                    Values = new List <int> {
                        2, 3, 4, 5
                    }
                },
                new Test3 {
                    Values = new List <int> {
                        10, 11, 12, 13
                    }
                }
            };

            var dct = new Dictionary <string, int>
            {
                ["Value1"] = 1,
                ["Value2"] = 2,
                ["Value3"] = 3,
            };

            var valSer     = collection.Where((item, i) => i % 2 == 0).SelectMany(i => i).OrderBy(i => i.FirstName);
            var valSerData = valSer.SerializeToNBinary();
            var valSer2    = valSerData.DeserializeFromNBinary <object>();

            var valSerData2 = valSer.SerializeToWBinary();
            var valSer3     = valSerData2.DeserializeFromWBinary <object>();

            RunTest(collection[0], 100_000, false);
        }