示例#1
0
        public void Run(int count)
        {
            var bigCount = count / 50;

            if (bigCount == 0)
            {
                bigCount = 1;
            }

            Log("");
            Log("BigByte array benchmark---------- repeat count: " + count);
            var bigByteArrray = new byte[short.MaxValue];

            for (short i = 0; i < 500; i++)
            {
                bigByteArrray[i] = 100;
            }

            RunBenchmarkBois(bigByteArrray, count);
            RunBenchmarkMsAvroPack(bigByteArrray, count);
            RunBenchmarkMessagePack(bigByteArrray, count);
            RunBenchmarkProtoBufNet(bigByteArrray, count);
            RunBenchmarkBinaryFormatter(bigByteArrray, count);
            RunBenchmarkNetSerializer(bigByteArrray, count);

            Log("");
            Log("ComplexContainer benchmark---------- repeat count: " + count);
            var objComplexContainer = ComplexContainer.CreateContainerArray(10);

            RunBenchmarkBois(objComplexContainer, count);
            RunBenchmarkMsAvroPack(objComplexContainer, count);
            RunBenchmarkMessagePack(objComplexContainer, count);
            RunBenchmarkProtoBufNet(objComplexContainer, count);
            RunBenchmarkBinaryFormatter(objComplexContainer, count);
            RunBenchmarkNetSerializer(objComplexContainer, count);

            Log("");
            Log("PrimitiveTypes.Simple benchmark---------- repeat count: " + count);
            var objPrimitiveTypes = PrimitiveTypes.CreateSimple();

            RunBenchmarkBois(objPrimitiveTypes, count);
            RunBenchmarkMsAvroPack(objPrimitiveTypes, count);
            RunBenchmarkMessagePack(objPrimitiveTypes, count);
            RunBenchmarkProtoBufNet(objPrimitiveTypes, count);
            RunBenchmarkBinaryFormatter(objPrimitiveTypes, count);
            RunBenchmarkNetSerializer(objPrimitiveTypes, count);

            Log("");
            Log("PrimitiveTypes.Big benchmark---------- repeat count: " + bigCount);
            objPrimitiveTypes = PrimitiveTypes.CreateBig();

            RunBenchmarkBois(objPrimitiveTypes, bigCount);
            RunBenchmarkMsAvroPack(objPrimitiveTypes, bigCount);
            RunBenchmarkMessagePack(objPrimitiveTypes, bigCount);
            RunBenchmarkProtoBufNet(objPrimitiveTypes, bigCount);
            RunBenchmarkBinaryFormatter(objPrimitiveTypes, bigCount);
            RunBenchmarkNetSerializer(objPrimitiveTypes, bigCount);

            Log("");
            Log("ArrayTypes.Simple benchmark---------- repeat count: " + count);
            var objArrayTypes = ArrayTypes.CreateSimple();

            RunBenchmarkBois(objArrayTypes, count);
            RunBenchmarkMsAvroPack(objArrayTypes, count);
            RunBenchmarkMessagePack(objArrayTypes, count);
            RunBenchmarkProtoBufNet(objArrayTypes, count);
            RunBenchmarkBinaryFormatter(objArrayTypes, count);
            RunBenchmarkNetSerializer(objArrayTypes, count);

            Log("");
            Log("ArrayTypes.Big benchmark---------- repeat count: " + bigCount);
            objArrayTypes = ArrayTypes.CreateBig();

            RunBenchmarkBois(objArrayTypes, bigCount);
            RunBenchmarkMsAvroPack(objArrayTypes, bigCount);
            RunBenchmarkMessagePack(objArrayTypes, bigCount);
            RunBenchmarkProtoBufNet(objArrayTypes, bigCount);
            RunBenchmarkBinaryFormatter(objArrayTypes, bigCount);
            RunBenchmarkNetSerializer(objArrayTypes, bigCount);

            Log("");
            Log("SimpleCollections.Simple benchmark---------- repeat count: " + count);
            var objStandardCollectionTypes = SimpleCollections.CreateSimple();

            RunBenchmarkBois(objStandardCollectionTypes, count);
            RunBenchmarkMsAvroPack(objStandardCollectionTypes, count);
            RunBenchmarkMessagePack(objStandardCollectionTypes, count);
            RunBenchmarkProtoBufNet(objStandardCollectionTypes, count);
            RunBenchmarkBinaryFormatter(objStandardCollectionTypes, count);
            RunBenchmarkNetSerializer(objStandardCollectionTypes, count);

            Log("");
            Log("SimpleCollections.Big benchmark---------- repeat count: " + bigCount);
            objStandardCollectionTypes = SimpleCollections.CreateBig();

            RunBenchmarkBois(objStandardCollectionTypes, bigCount);
            RunBenchmarkMsAvroPack(objStandardCollectionTypes, bigCount);
            RunBenchmarkMessagePack(objStandardCollectionTypes, bigCount);
            RunBenchmarkProtoBufNet(objStandardCollectionTypes, bigCount);
            RunBenchmarkBinaryFormatter(objStandardCollectionTypes, bigCount);
            RunBenchmarkNetSerializer(objStandardCollectionTypes, bigCount);

            Log("");
            Log("ComplexCollections.Simple benchmark---------- repeat count: " + count);
            var objComplexCollections = ComplexCollections.CreateSimple();

            RunBenchmarkBois(objComplexCollections, count);
            RunBenchmarkMsAvroPack(objComplexCollections, count);
            RunBenchmarkMessagePack(objComplexCollections, count);
            RunBenchmarkProtoBufNet(objComplexCollections, count);
            RunBenchmarkBinaryFormatter(objComplexCollections, count);
            RunBenchmarkNetSerializer(objComplexCollections, count);

            Log("");
            Log("ComplexCollections.Big benchmark---------- repeat count: " + bigCount);
            var objComplexCollections2 = ComplexCollections.CreateBig();

            RunBenchmarkBois(objComplexCollections2, bigCount);
            RunBenchmarkMsAvroPack(objComplexCollections2, bigCount);
            RunBenchmarkMessagePack(objComplexCollections2, bigCount);
            RunBenchmarkProtoBufNet(objComplexCollections2, bigCount);
            RunBenchmarkBinaryFormatter(objComplexCollections2, bigCount);
            RunBenchmarkNetSerializer(objComplexCollections2, bigCount);

            Log("");
            Log("SpecializedCollections.Simple benchmark---------- repeat count: " + count);
            var objSpecializedCollections = SpecializedCollections.CreateSimple();

            RunBenchmarkBois(objSpecializedCollections, count);
            RunBenchmarkMsAvroPack(objSpecializedCollections, count);
            RunBenchmarkMessagePack(objSpecializedCollections, count);
            RunBenchmarkProtoBufNet(objSpecializedCollections, count);
            RunBenchmarkBinaryFormatter(objSpecializedCollections, count);
            RunBenchmarkNetSerializer(objSpecializedCollections, count);

            Log("");
            Log("Contained Collection benchmark---------- repeat count: " + count);
            var objContainedListChild = ContainedListChild.CreateSimple();

            RunBenchmarkBois(objContainedListChild, count);
            RunBenchmarkMsAvroPack(objContainedListChild, count);
            RunBenchmarkMessagePack(objContainedListChild, count);
            RunBenchmarkProtoBufNet(objContainedListChild, count);
            RunBenchmarkBinaryFormatter(objContainedListChild, count);
            RunBenchmarkNetSerializer(objContainedListChild, count);
        }