Beispiel #1
0
        public void Deserialize_SimplePerson_Arow()
        {
            const int CNT = 250000;

            var row = getSimplePerson();

            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 SimplePersonRow();
                    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));
            }
        }
Beispiel #2
0
        public void SerDeser_OneSimplePerson()
        {
            var row1 = 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 SimplePersonRow();
                reader.BindStream(ms);
                ArowSerializer.Deserialize(row2, reader);
                reader.UnbindStream();

                Aver.AreEqual(row1.ID, row2.ID);
                Aver.AreEqual(row1.Bool1, row2.Bool1);
                Aver.AreEqual(row1.Name, row2.Name);
                Aver.AreEqual(row1.Age, row2.Age);
                Aver.AreEqual(row1.Salary, row2.Salary);
                Aver.AreEqual(row1.Str1, row2.Str1);
                Aver.AreEqual(row1.Date, row2.Date);
            }
        }
Beispiel #3
0
        public void Deserialize_SimplePerson_Arow(int CNT, int tcnt)
        {
            var row = getSimplePerson();


            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 SimplePersonRow();
                        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)));
        }