[rabbitmq-discuss] Simple benchmark and results

David Glaubman dglaubman at acm.org
Thu Oct 22 21:46:46 BST 2009


Matthias,

Oops -- I uploaded the original NetworkBinaryWriter not the modified version
I used for the test s.

Here is the relevant code:

       /// <summary>
        /// Override BinaryWriter's method for network-order.
        /// </summary>
        public override void Write(short i) {
            buffer[0] = (byte)(i >> 8);
            buffer[1] = (byte)i;
            WriteBuffer(2);
        }

        /// <summary>
        /// Override BinaryWriter's method for network-order.
        /// </summary>
        public override void Write(ushort i) {
            buffer[0] = (byte)(i >> 8);
            buffer[1] = (byte)i;
            WriteBuffer(2);
        }

        /// <summary>
        /// Override BinaryWriter's method for network-order.
        /// </summary>
        public override void Write(int i) {
            buffer[0] = (byte)(i >> 24);
            buffer[1] = (byte)(i >> 16);
            buffer[2] = (byte)(i >> 8);
            buffer[3] = (byte)(i);
            WriteBuffer(4);
        }

        /// <summary>
        /// Override BinaryWriter's method for network-order.
        /// </summary>
        public override void Write(uint i)
        {
            buffer[0] = (byte)(i >> 24);
            buffer[1] = (byte)(i >> 16);
            buffer[2] = (byte)(i >> 8);
            buffer[3] = (byte)(i);
            WriteBuffer(4);
        }

        /// <summary>
        /// Override BinaryWriter's method for network-order.
        /// </summary>
        public override void Write(long i) {
            buffer[0] = (byte)(i >> 56);
            buffer[1] = (byte)(i >> 48);
            buffer[2] = (byte)(i >> 40);
            buffer[3] = (byte)(i >> 32);
            buffer[4] = (byte)(i >> 24);
            buffer[5] = (byte)(i >> 16);
            buffer[6] = (byte)(i >> 8);
            buffer[7] = (byte) (i);
            WriteBuffer(8);
        }

        /// <summary>
        /// Override BinaryWriter's method for network-order.
        /// </summary>
        public override void Write(ulong i) {
            buffer[0] = (byte)(i >> 56);
            buffer[1] = (byte)(i >> 48);
            buffer[2] = (byte)(i >> 40);
            buffer[3] = (byte)(i >> 32);
            buffer[4] = (byte)(i >> 24);
            buffer[5] = (byte)(i >> 16);
            buffer[6] = (byte)(i >> 8);
            buffer[7] = (byte)(i);
            WriteBuffer(8);
        }

        private byte[] buffer = new byte[8];
        private void WriteBuffer(int n)
        {
            OutStream.Write(buffer, 0, n);
        }


-- 
View this message in context: http://www.nabble.com/Simple-benchmark-and-results-tp25968960p26016912.html
Sent from the RabbitMQ mailing list archive at Nabble.com.





More information about the rabbitmq-discuss mailing list