예제 #1
0
        void Warmup()
        {
            var msgs = new MessageBase[] { new S16Message(), new ComplexMessage(), new IntArrayMessage() };

            IMemStreamTest t;

            t = new MemStreamTest(m_serializer);
            t.Prepare(msgs.Length);
            t.Serialize(msgs);
            t.Deserialize();

            if (Program.RunProtoBufTests)
            {
                t = new PBMemStreamTest();
                t.Prepare(msgs.Length);
                t.Serialize(msgs);
                t.Deserialize();
            }
        }
        void Test(MemStreamTest <T> test, T[] msgs, int loops)
        {
            test.Prepare();

            /* Serialize part */
            {
                Console.Write("{0,-13} | {1,-21} | ", test.Specimen.Name, "MemStream Serialize");
                Console.Out.Flush();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                var c0 = GC.CollectionCount(0);
                var c1 = GC.CollectionCount(1);
                var c2 = GC.CollectionCount(2);

                var sw = Stopwatch.StartNew();

                long size = 0;
                for (int l = 0; l < loops; ++l)
                {
                    size = test.Serialize(msgs, m_direct);
                }

                sw.Stop();

                c0 = GC.CollectionCount(0) - c0;
                c1 = GC.CollectionCount(1) - c1;
                c2 = GC.CollectionCount(2) - c2;

                Console.WriteLine("{0,10} | {1,4} {2,3} {3,3} | {4,10} |", sw.ElapsedMilliseconds, c0, c1, c2, size);
            }

            /* Deserialize part */

            {
                var received = new T[msgs.Length];

                Console.Write("{0,-13} | {1,-21} | ", test.Specimen.Name, "MemStream Deserialize");
                Console.Out.Flush();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                var c0 = GC.CollectionCount(0);
                var c1 = GC.CollectionCount(1);
                var c2 = GC.CollectionCount(2);

                var sw = Stopwatch.StartNew();

                for (int l = 0; l < loops; ++l)
                {
                    test.Deserialize(received, m_direct);
                }

                sw.Stop();

                c0 = GC.CollectionCount(0) - c0;
                c1 = GC.CollectionCount(1) - c1;
                c2 = GC.CollectionCount(2) - c2;

                Console.WriteLine("{0,10} | {1,4} {2,3} {3,3} | {4,10} |", sw.ElapsedMilliseconds, c0, c1, c2, "");

                if (Program.EnableResultCheck)
                {
                    CompareMessages(msgs, received);
                }
            }
        }
예제 #3
0
        void Warmup()
        {
            var msgs = new MessageBase[] { new S16Message(), new ComplexMessage(), new IntArrayMessage() };

            IMemStreamTest t;

            t = new MemStreamTest(m_serializer);
            t.Prepare(msgs.Length);
            t.Serialize(msgs);
            t.Deserialize();

            if (Program.RunProtoBufTests)
            {
                t = new PBMemStreamTest();
                t.Prepare(msgs.Length);
                t.Serialize(msgs);
                t.Deserialize();
            }
        }