测试string.Format、$、MessagePack、Ze

2017-07-28  本文已影响50人  Brent姜

对如下数据类生成用于Dictionary存储的Key值:

[DataContract]
[ZeroFormattable]
[MessagePackObject]
public class STPInvestorPositionField
{
    ///投资者代码
    [Index(0)]
    [Key(0)]
    [DataMember]
    public virtual string InvestorID { get; set; }
    ///交易所代码
    [Index(1)]
    [Key(1)]
    [DataMember]
    public virtual string ExchangeID { get; set; }
    ///策略代码
    [Index(2)]
    [Key(2)]
    [DataMember]
    public virtual string ComboID { get; set; }
    ///合约代码
    [Index(3)]
    [Key(3)]
    [DataMember]
    public virtual string InstrumentID { get; set; }
};

测试说明

测试机器:


测试台式机配置简要信息

测试结果

[Debug mode]
$string (tenths of ms) 5642
string.Format (tenths of ms) 5959
ZeroFormatterSerializer.Serialize (tenths of ms) 21483, Convert.ToBase64String() used.
MessagePackSerializer.Serialize (tenths of ms) 8077
MessagePackSerializer.Serialize (tenths of ms) 11223, Convert.ToBase64String() used.
MessagePackSerializer.Serialize (tenths of ms) 12362, Encoding.Default.GetString() used.
DataContractJsonSerializer (tenths of ms) 47525
Newtonsoft.Json (tenths of ms) 37426

[Release mode]
$string (tenths of ms) 5695
string.Format (tenths of ms) 6953
ZeroFormatterSerializer.Serialize (tenths of ms) 13883, Convert.ToBase64String() used.
MessagePackSerializer.Serialize (tenths of ms) 7648
MessagePackSerializer.Serialize (tenths of ms) 10530, Convert.ToBase64String() used.
MessagePackSerializer.Serialize (tenths of ms) 11800, Encoding.Default.GetString() used.
DataContractJsonSerializer (tenths of ms) 47304
Newtonsoft.Json (tenths of ms) 35031

测试结果说明:

上一篇 下一篇

猜你喜欢

热点阅读