コード例 #1
0
ファイル: Program.cs プロジェクト: Elders/Proteus
        public static void MeasureSerialization <T>(string header, T instance, int numberofTimes)
        {
            Console.WriteLine("============{0}============", header);
            guidProteus.SerializeWithHeaders(new MemoryStream(), instance);
            var proteusResult = MeasureExecutionTime.Start(() => guidProteus.SerializeWithHeaders(new MemoryStream(), instance), numberofTimes);

            Console.WriteLine("Guid Proteus: " + proteusResult);

            var jsonSer    = new Json(new ContractsRepository(typeof(SimpleObject).Assembly.GetTypes().Where(x => x.HasAttribute <DataContractAttribute>())));
            var jsonResult = MeasureExecutionTime.Start(() => jsonSer.Serialize(instance), numberofTimes);

            Console.WriteLine("Json Net : " + jsonResult);
            //stringProteus.SerializeWithHeaders(new MemoryStream(), instance);
            //var sproteusResult = MeasureExecutionTime.Start(() => stringProteus.SerializeWithHeaders(new MemoryStream(), instance), numberofTimes);
            //Console.WriteLine("String Proteus: " + sproteusResult);

            protoreg.Serialize(new MemoryStream(), instance);
            var protoregResult = MeasureExecutionTime.Start(() => protoreg.Serialize(new MemoryStream(), instance), numberofTimes);

            Console.WriteLine("Protoreg: " + protoregResult);
            ProtoBuf.Serializer.Serialize(new MemoryStream(), instance);
            var protobuffResult = MeasureExecutionTime.Start(() => ProtoBuf.Serializer.Serialize(new MemoryStream(), instance), numberofTimes);

            Console.WriteLine("Protobuff" + protobuffResult);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Elders/Proteus
        public static void MeasureDeserialization <T>(string header, T instance, int numberofTimes)
        {
            Console.WriteLine("============{0}============", header);


            var proteusStream = new MemoryStream();

            guidProteus.SerializeWithHeaders(proteusStream, instance);
            proteusStream.Position = 0;
            var proteusResult = MeasureExecutionTime.Start(() =>
            {
                proteusStream.Position = 0;
                var des = guidProteus.DeserializeWithHeaders(proteusStream);
            }, numberofTimes);

            Console.WriteLine("Guid Proteus: " + proteusResult);

            //var sproteusStream = new MemoryStream();
            //stringProteus.SerializeWithHeaders(sproteusStream, instance);
            //sproteusStream.Position = 0;
            //var sproteusResult = MeasureExecutionTime.Start(() =>
            //{
            //    sproteusStream.Position = 0;
            //    var des = stringProteus.DeserializeWithHeaders(sproteusStream);

            //}, numberofTimes);
            //Console.WriteLine("String Proteus: " + sproteusResult);

            var protoregStream = new MemoryStream();

            protoreg.Serialize(protoregStream, instance);
            var protoregResult = MeasureExecutionTime.Start(() =>
            {
                protoregStream.Position = 0;
                var des = protoreg.Deserialize(protoregStream);
            }, numberofTimes);

            Console.WriteLine("Protoreg: " + protoregResult);

            var protobuffStream = new MemoryStream();

            ProtoBuf.Serializer.Serialize(protobuffStream, instance);
            var protobuffResult = MeasureExecutionTime.Start(() =>
            {
                protobuffStream.Position = 0;
                var des = ProtoBuf.Serializer.Deserialize <T>(protobuffStream);
            }, numberofTimes);

            Console.WriteLine("Protobuff" + protobuffResult);
        }