コード例 #1
0
        public void TimeTest2()
        {
            MarshalMemoryBlock memory = new MarshalMemoryBlock((long)(1024 * 1024 * 1024) * 3);

            DateTime dt   = DateTime.Now;
            long     ltmp = (long)(1024 * 1024);

            memory.WriteByte(ltmp, (byte)20);
            memory.WriteDatetime(memory.Position, dt);
            memory.WriteDouble(memory.Position, 20.5);
            memory.WriteFloat(memory.Position, 20.5f);
            memory.WriteString(memory.Position, dt.ToString(), Encoding.Unicode);
            memory.WriteInt(memory.Position, 20);
            memory.WriteLong(memory.Position, 20);
            memory.WriteShort(memory.Position, (short)20);
            memory.WriteUShort(memory.Position, (ushort)20);
            memory.WriteUInt(memory.Position, 20);
            memory.WriteULong(memory.Position, 20);

            MarshalMemoryBlock mm = new MarshalMemoryBlock(1024);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int i = 0; i < 1000000; i++)
            {
                memory.WriteBytesDirect(500, memory.StartMemory + (int)ltmp, 0, 50);
                memory.WriteUShortDirect(550, 50);
                memory.WriteByte(550, 1);
            }
            sw.Stop();
            Debug.Print("10000000:" + sw.ElapsedMilliseconds);
        }