public void FromBytes(int iteration) { #pragma warning disable CS0618 var binaryBytes = BinaryHelper.ToBytes(_testModel); #pragma warning restore CS0618 var dataContractBytes = DataContractHelper.ToBytes <TestModel>(_testModel); var jilBytes = JilHelper.ToBytes <TestModel>(_testModel); var messagePackBytes = MessagePackHelper.ToBytes <TestModel>(_testModel); var msgPackBytes = MsgPackHelper.ToBytes <TestModel>(_testModel); var newtonsoftJsonBytes = NewtonsoftJsonHelper.ToBytes <TestModel>(_testModel); var protobufBytes = ProtobufHelper.ToBytes <TestModel>(_testModel); var sharpYamlBytes = SharpYamlHelper.ToBytes <TestModel>(_testModel); var systemTextJsonBytes = SystemTextJsonHelper.ToBytes <TestModel>(_testModel); var utf8JsonBytes = Utf8JsonHelper.ToBytes <TestModel>(_testModel); var xmlBytes = XmlHelper.ToBytes <TestModel>(_testModel); var yamlDotNetBytes = YamlDotNetHelper.ToBytes(_testModel); var zeroFormatterBytes = ZeroFormatterHelper.ToBytes <TestModel>(_testModel); Console.WriteLine("FromBytes go!"); Runner.Initialize(); Console.WriteLine(Runner.Time("BinaryHelper FromBytes", iteration, #pragma warning disable CS0618 () => BinaryHelper.FromBytes <TestModel>(binaryBytes))); #pragma warning restore CS0618 Console.WriteLine(Runner.Time("DataContractHelper FromBytes", iteration, () => DataContractHelper.FromBytes <TestModel>(dataContractBytes))); Console.WriteLine(Runner.Time("JilHelper FromBytes", iteration, () => JilHelper.FromBytes <TestModel>(jilBytes))); Console.WriteLine(Runner.Time("MessagePackHelper FromBytes", iteration, () => MessagePackHelper.FromBytes <TestModel>(messagePackBytes))); Console.WriteLine(Runner.Time("MsgPackHelper FromBytes", iteration, () => MsgPackHelper.FromBytes <TestModel>(msgPackBytes))); Console.WriteLine(Runner.Time("NewtonsoftJsonHelper FromBytes", iteration, () => NewtonsoftJsonHelper.FromBytes <TestModel>(newtonsoftJsonBytes))); Console.WriteLine(Runner.Time("ProtobufHelper FromBytes", iteration, () => ProtobufHelper.FromBytes <TestModel>(protobufBytes))); Console.WriteLine(Runner.Time("SharpYamlHelper FromBytes", iteration, () => SharpYamlHelper.FromBytes <TestModel>(sharpYamlBytes))); Console.WriteLine(Runner.Time("SystemTextJsonHelper FromBytes", iteration, () => SystemTextJsonHelper.FromBytes <TestModel>(systemTextJsonBytes))); Console.WriteLine(Runner.Time("Utf8JsonHelper FromBytes", iteration, () => Utf8JsonHelper.FromBytes <TestModel>(utf8JsonBytes))); Console.WriteLine(Runner.Time("XmlHelper FromBytes", iteration, () => XmlHelper.FromBytes <TestModel>(xmlBytes))); Console.WriteLine(Runner.Time("YamlDotNetHelper FromBytes", iteration, () => YamlDotNetHelper.FromBytes <TestModel>(yamlDotNetBytes))); Console.WriteLine(Runner.Time("ZeroFormatterHelper FromBytes", iteration, () => ZeroFormatterHelper.FromBytes <TestModel>(zeroFormatterBytes))); Console.WriteLine("\r\nFromBytes complete!\r\n"); }
public void ToBytes(int iteration) { Console.WriteLine("ToBytes go!"); Runner.Initialize(); Console.WriteLine(Runner.Time("BinaryHelper ToBytes", iteration, #pragma warning disable CS0618 () => BinaryHelper.ToBytes(_testModel))); #pragma warning restore CS0618 Console.WriteLine(Runner.Time("DataContractHelper ToBytes", iteration, () => DataContractHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("JilHelper ToBytes", iteration, () => JilHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("MessagePackHelper ToBytes", iteration, () => MessagePackHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("MsgPackHelper ToBytes", iteration, () => MsgPackHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("NewtonsoftJsonHelper ToBytes", iteration, () => NewtonsoftJsonHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("ProtobufHelper ToBytes", iteration, () => ProtobufHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("SharpYamlHelper ToBytes", iteration, () => SharpYamlHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("SystemTextJsonHelper ToBytes", iteration, () => SystemTextJsonHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("Utf8JsonHelper ToBytes", iteration, () => Utf8JsonHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("XmlHelper ToBytes", iteration, () => XmlHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("YamlDotNetHelper ToBytes", iteration, () => YamlDotNetHelper.ToBytes(_testModel))); Console.WriteLine(Runner.Time("ZeroFormatterHelper ToBytes", iteration, () => ZeroFormatterHelper.ToBytes(_testModel))); Console.WriteLine("\r\nToBytes complete!\r\n"); }
public static byte[] ToBytes(this object?value, Type type, MessagePackSerializerOptions?options = null, CancellationToken cancellationToken = default) => MessagePackHelper.ToBytes(type, value, options, cancellationToken);
public static byte[] ToBytes <TValue>(this TValue?value, MessagePackSerializerOptions?options = null, CancellationToken cancellationToken = default) => MessagePackHelper.ToBytes(value, options, cancellationToken);