Пример #1
0
        public void Deserialize_Family_Arow(int CNT, int tcnt)
        {
            var row = getFamily();

            var tasks = new List <Task>();
            var sw    = Stopwatch.StartNew();

            tasks.Add(Task.Factory.StartNew(() =>
            {
                var writer = SlimFormat.Instance.GetWritingStreamer();
                var reader = SlimFormat.Instance.GetReadingStreamer();

                using (var ms = new MemoryStream())
                {
                    writer.BindStream(ms);
                    ArowSerializer.Serialize(row, writer);
                    writer.UnbindStream();
                    reader.BindStream(ms);

                    for (var i = 0; i < CNT; i++)
                    {
                        ms.Position = 0;
                        var row2    = new FamilyRow();
                        ArowSerializer.Deserialize(row2, reader);
                        Aver.AreEqual(row.ID, row2.ID);
                    }
                }
            }));

            Task.WaitAll(tasks.ToArray());
            var el    = sw.ElapsedMilliseconds;
            var total = CNT * tcnt;

            Console.WriteLine("Arow did {0:n0} in {1:n0} ms at {2:n0} ops/sec".Args(total, el, total / (el / 1000d)));
        }
Пример #2
0
        public void Deserialize_Family_Arow()
        {
            const int CNT = 250000;

            var row = getFamily();

            var writer = SlimFormat.Instance.GetWritingStreamer();
            var reader = SlimFormat.Instance.GetReadingStreamer();

            using (var ms = new MemoryStream())
            {
                writer.BindStream(ms);
                ArowSerializer.Serialize(row, writer);
                writer.UnbindStream();
                reader.BindStream(ms);

                var sw = Stopwatch.StartNew();
                for (var i = 0; i < CNT; i++)
                {
                    ms.Position = 0;
                    var row2 = new FamilyRow();
                    ArowSerializer.Deserialize(row2, reader);
                    Aver.AreEqual(row.ID, row2.ID);
                }

                var el = sw.ElapsedMilliseconds;
                Console.WriteLine("Arow did {0:n0} in {1:n0} ms at {2:n0} ops/sec. Stream Size is: {3:n0} bytes".Args(CNT, el, CNT / (el / 1000d), ms.Length));
            }
        }
Пример #3
0
        public void SerDeser_FamilyRow_1_NoReferences()
        {
            var row1 = new FamilyRow
            {
                ID = new GDID(1, 345), Name = "Lalala", RegisteredToVote = true,

                //Father = new SimplePersonRow
                //{
                //  Age = 123, Bool1 =true, ID = new GDID(12,234), Name = "Jacques Jabakz", Salary=143098, Str1="Tryten", Date = new DateTime(1980, 08, 12, 13, 45, 11)
                //}
            };

            var writer = SlimFormat.Instance.GetWritingStreamer();
            var reader = SlimFormat.Instance.GetReadingStreamer();

            using (var ms = new MemoryStream())
            {
                writer.BindStream(ms);
                ArowSerializer.Serialize(row1, writer);
                writer.UnbindStream();

                ms.Position = 0;

                var row2 = new FamilyRow();
                reader.BindStream(ms);
                ArowSerializer.Deserialize(row2, reader);
                reader.UnbindStream();

                Aver.AreEqual(row1.ID, row2.ID);
                Aver.AreEqual(row1.Name, row2.Name);
            }
        }
Пример #4
0
        public void SerDeser_FamilyRow_4_EmptyArray()
        {
            var row1 = new FamilyRow
            {
                ID = new GDID(1, 345), Name = "Lalala", RegisteredToVote = true,

                Father = new SimplePersonRow
                {
                    Age = 123, Bool1 = true, ID = new GDID(12, 234), Name = "Jacques Jabakz", Salary = 143098, Str1 = "Tryten", Date = new DateTime(1980, 08, 12, 13, 45, 11)
                },
                Mother = new SimplePersonRow
                {
                    Age = 245, Bool1 = false, ID = new GDID(2, 12), Name = "Katya Zhaba", Salary = 180000, Str1 = "Snake", Str2 = "Borra", Date = new DateTime(1911, 01, 01, 14, 11, 07)
                },
                Brothers = new SimplePersonRow[0],
            };

            var writer = SlimFormat.Instance.GetWritingStreamer();
            var reader = SlimFormat.Instance.GetReadingStreamer();

            using (var ms = new MemoryStream())
            {
                writer.BindStream(ms);
                ArowSerializer.Serialize(row1, writer);
                writer.UnbindStream();

                ms.Position = 0;

                var row2 = new FamilyRow();
                reader.BindStream(ms);
                ArowSerializer.Deserialize(row2, reader);
                reader.UnbindStream();

                Aver.AreNotSameRef(row1, row2);
                Aver.AreEqual(row1.ID, row2.ID);
                Aver.AreEqual(row1.Name, row2.Name);
                Aver.AreEqual(row1.RegisteredToVote, row2.RegisteredToVote);
                Aver.IsNotNull(row2.Father);
                Aver.AreEqual(row1.Father.ID, row2.Father.ID);
                Aver.AreEqual(row1.Father.Age, row2.Father.Age);
                Aver.AreEqual(row1.Father.Str1, row2.Father.Str1);

                Aver.AreEqual(row1.Father.Date, row2.Father.Date);
                Aver.IsNull(row2.Father.Str2);

                Aver.IsNotNull(row2.Mother);
                Aver.AreEqual(row1.Mother.ID, row2.Mother.ID);
                Aver.AreEqual(row1.Mother.Age, row2.Mother.Age);
                Aver.AreEqual(row1.Mother.Str1, row2.Mother.Str1);
                Aver.IsNotNull(row2.Mother.Str2);
                Aver.AreEqual(row1.Mother.Str2, row2.Mother.Str2);
                Aver.AreEqual(row1.Mother.Date, row2.Mother.Date);

                Aver.IsNotNull(row2.Brothers);
                Aver.AreEqual(0, row2.Brothers.Length);
                Aver.IsNull(row2.Sisters);
                Aver.IsNull(row2.Advisers);
            }
        }