举例如下:
第1类序列化所需时间是第2类序列化的近两倍吗?还是原生泡沫-网络将第1类中的字节作为已经序列化的数据处理?
Pseudo 示例 :
[ProtoContract]
class Class1
{
[ProtoMember(1)]
public byte[] SerializedData { get; set; }
}
[ProtoContract]
class Class2
{
[ProtoMember(1)]
public Class3 NonSerializedData { get; set; }
}
[ProtoContract]
class Class3
{
[ProtoMember(1)]
public string Address{ get; set; }
[ProtoMember(2)]
public string ZipCode{ get; set; }
[ProtoMember(2)]
public string Country{ get; set; }
}
Class3 _c3 = new Class3() { Address = "MyAddress", ZipCode = "90210", Country = "AZ" }
// Class 1 Serialization
Class1 _c1 = new C1();
_c1.SerializedData = protobuf.Serialize(_c3);
byte[] c1Bytes = protobuf.Serialize(_c1);
// Class 2 Serialization
Class2 _c2 = new Class2();
_c2.NonSerializedData = _c3;
byte[] c2Bytes = protobuf.Serialize(_c2);