예제 #1
0
        static void Test(IMemStreamTest test, MessageBase[] msgs)
        {
            test.Prepare(msgs.Length);

            /* Serialize part */
            {
                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 = test.Serialize(msgs);

                sw.Stop();

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

                Console.WriteLine("{0,-13} | {1,-21} | {2,10} | {3,3} {4,3} {5,3} | {6,10} |",
                    test.Framework, "MemStream Serialize", sw.ElapsedMilliseconds, c0, c1, c2, size);
            }

            /* Deerialize part */

            {
                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();

                var received = test.Deserialize();

                sw.Stop();

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

                Console.WriteLine("{0,-13} | {1,-21} | {2,10} | {3,3} {4,3} {5,3} | {6,10} |",
                    test.Framework, "MemStream Deserialize", sw.ElapsedMilliseconds, c0, c1, c2, "");

                for (int i = 0; i < msgs.Length; ++i)
                {
                    var msg1 = msgs[i];
                    var msg2 = received[i];

                    msg1.Compare(msg2);
                }
            }
        }
예제 #2
0
        static void Test(IMemStreamTest test, MessageBase[] msgs)
        {
            test.Prepare(msgs.Length);

            /* Serialize part */
            {
                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 = test.Serialize(msgs);

                sw.Stop();

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

                Console.WriteLine("{0,-13} | {1,-21} | {2,10} | {3,3} {4,3} {5,3} | {6,10} |",
                                  test.Framework, "MemStream Serialize", sw.ElapsedMilliseconds, c0, c1, c2, size);
            }

            /* Deerialize part */

            {
                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();

                var received = test.Deserialize();

                sw.Stop();

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

                Console.WriteLine("{0,-13} | {1,-21} | {2,10} | {3,3} {4,3} {5,3} | {6,10} |",
                                  test.Framework, "MemStream Deserialize", sw.ElapsedMilliseconds, c0, c1, c2, "");

                if (Program.EnableResultCheck)
                {
                    for (int i = 0; i < msgs.Length; ++i)
                    {
                        var msg1 = msgs[i];
                        var msg2 = received[i];

                        msg1.Compare(msg2);
                    }
                }
            }
        }