示例#1
0
 public void Test7Bit4()
 {
     byte[] data = new byte[4096 * 5];
     fixed(byte *lp = data)
     {
         using (BinaryStreamPointerWrapper bs = new BinaryStreamPointerWrapper(lp, data.Length))
         {
             DebugStopwatch sw   = new DebugStopwatch();
             double         time = sw.TimeEventMedian(() =>
             {
                 for (int repeat = 0; repeat < 1000; repeat++)
                 {
                     bs.Position = 0;
                     for (int x = 0; x < 1000; x++)
                     {
                         bs.Write7Bit(128u * 128u * 128u);
                         bs.Write7Bit(128u * 128u * 128u);
                         bs.Write7Bit(128u * 128u * 128u);
                         bs.Write7Bit(128u * 128u * 128u);
                     }
                 }
             });
             Console.WriteLine(4 * 1000 * 1000 / time / 1000 / 1000);
         }
     }
 }
        public void Test7Bit2()
        {
            byte[] data = new byte[4096 * 5];
            fixed (byte* lp = data)
            {
                using (var bs = new BinaryStreamPointerWrapper(lp, data.Length))
                {
                    DebugStopwatch sw = new DebugStopwatch();
                    var time = sw.TimeEventMedian(() =>
                    {
                        for (int repeat = 0; repeat < 1000; repeat++)
                        {
                            bs.Position = 0;
                            for (int x = 0; x < 1000; x++)
                            {
                                bs.Write7Bit(128u);
                                bs.Write7Bit(128u);
                                bs.Write7Bit(128u);
                                bs.Write7Bit(128u);
                            }
                        }

                    });
                    Console.WriteLine((4 * 1000 * 1000) / time / 1000 / 1000);
                }
            }
        }
        public void TestWriteLong()
        {
            byte[] data = new byte[4096 * 8];
            fixed(byte *lp = data)
            {
                using (var bs = new BinaryStreamPointerWrapper(lp, data.Length))
                {
                    DebugStopwatch sw   = new DebugStopwatch();
                    var            time = sw.TimeEventMedian(() =>
                    {
                        for (int repeat = 0; repeat < 1000; repeat++)
                        {
                            bs.Position = 0;
                            for (int x = 0; x < 1000; x++)
                            {
                                bs.Write((long)x);
                                bs.Write((long)x);
                                bs.Write((long)x);
                                bs.Write((long)x);
                            }
                        }
                    });

                    Console.WriteLine((4 * 1000 * 1000) / time / 1000 / 1000);
                }
            }
        }