コード例 #1
0
        static void testFormat()
        {
            var obj = new testClass()
            {
            };

            //obj.b = new b() { name = "b22424" };
            //obj.dic = new Dictionary<string, object>() { { "tes111111111112t", 1 }, { "t2222222222122est2", 1 }, { "te22222221s3t", 1 } };
            obj.name  = "test2ConvertObject";
            obj.time  = DateTime.Now;
            obj.price = 1002;
            //obj.name2 = "sss";
            obj.price2 = 2;
            obj.price3 = 10;
            int count = 1;


            new CounterWatch().Start("testJson", () =>
            {
                testJson(obj);
            }, count);

            new CounterWatch().Start("testBinary", () =>
            {
                testBinary(obj);
            }, count);
            new CounterWatch().Start("testProtobuf", () =>
            {
                testProtobuf(obj);
            }, count);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: zyj0021/CRL5
        static int testBinary(testClass obj)
        {
            var data = CRL.Core.BinaryFormat.ClassFormat.Pack(obj.GetType(), obj);
            var obj2 = CRL.Core.BinaryFormat.ClassFormat.UnPack(obj.GetType(), data);

            return(0);
        }
コード例 #3
0
        static int testBinary(testClass obj)
        {
            var data = CRL.Core.BinaryFormat.ClassFormat.Pack(obj.GetType(), obj);

            //var obj2 = CRL.Core.BinaryFormat.ClassFormat.UnPack(obj.GetType(), data);
            Console.WriteLine(data.Length);
            return(data.Length);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: zyj0021/CRL5
        static int testJson(testClass obj)
        {
            var json = SerializeHelper.SerializerToJson(obj);
            var obj2 = SerializeHelper.DeserializeFromJson <testClass>(json);

            //var buffer = System.Text.Encoding.UTF8.GetBytes(json);
            return(0);
        }
コード例 #5
0
        static int testJson(testClass obj)
        {
            var json = SerializeHelper.SerializerToJson(obj);
            var len  = Encoding.UTF8.GetBytes(json).Length;

            Console.WriteLine(len);
            //var obj2 = SerializeHelper.DeserializeFromJson<testClass>(json);
            return(len);
        }
コード例 #6
0
 static int testProtobuf(testClass obj)
 {
     using (var ms = new System.IO.MemoryStream())
     {
         ProtoBuf.Serializer.Serialize(ms, obj);
         //var obj2 = ProtoBuf.Serializer.Deserialize<testClass>(ms);
         Console.WriteLine(ms.Length);
         return((int)ms.Length);
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: zyj0021/CRL5
        static void testFormat()
        {
            var obj = new testClass()
            {
            };

            //obj.b = new b() { name = "b22424" };
            //obj.dic = new Dictionary<string, object>() { { "tes111111111112t", 1 }, { "t2222222222122est2", 1 }, { "te22222221s3t", 1 } };
            obj.name  = "test2ConvertObject";
            obj.time  = DateTime.Now;
            obj.price = 1002;
            int count = 1000;

            new CounterWatch().Start("json", () =>
            {
                testJson(obj);
            }, count);
            //var data = CRL.Core.BinaryFormat.ClassFormat.Pack(obj.GetType(), obj);
            new CounterWatch().Start("binary", () =>
            {
                //var obj2 = CRL.Core.BinaryFormat.ClassFormat.UnPack(obj.GetType(), data);
                testBinary(obj);
            }, count);
        }