-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathBinaryBenchmark.MsgPack.cs
More file actions
25 lines (21 loc) · 876 Bytes
/
BinaryBenchmark.MsgPack.cs
File metadata and controls
25 lines (21 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using BenchmarkDotNet.Attributes;
using MsgPack.Serialization;
using SerializationBenchmarks.Models;
public partial class BinaryBenchmark
{
private readonly MessagePackSerializer<List<User>> _msgPackSerializer = MessagePackSerializer.Get<List<User>>();
[Benchmark, BenchmarkCategory("Serialization", "Binary"), ArgumentsSource(nameof(GenerateDataSets))]
public byte[] MsgPack_Serialize(DataSet data)
{
return DataConvert_MsgPack(data.Payload);
}
[Benchmark, BenchmarkCategory("Deserialization", "Binary"), ArgumentsSource(nameof(GenerateDataSets))]
public List<User> MsgPack_Deserialize(DataSet data)
{
return _msgPackSerializer.UnpackSingleObject(data.SerializedData.MsgPack);
}
private byte[] DataConvert_MsgPack(List<User> users)
{
return _msgPackSerializer.PackSingleObject(users);
}
}