-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathBinaryBenchmark.Hyperion.cs
More file actions
30 lines (25 loc) · 975 Bytes
/
BinaryBenchmark.Hyperion.cs
File metadata and controls
30 lines (25 loc) · 975 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
26
27
28
29
30
using BenchmarkDotNet.Attributes;
using Hyperion;
using SerializationBenchmarks.Models;
public partial class BinaryBenchmark
{
private readonly Serializer _hyperionSerializer= new Hyperion.Serializer();
[Benchmark, BenchmarkCategory("Serialization", "Binary"), ArgumentsSource(nameof(GenerateDataSets))]
public byte[] Hyperion_Serialize(DataSet data)
{
return DataConvert_Hyperion(data.Payload);
}
[Benchmark, BenchmarkCategory("Deserialization", "Binary"), ArgumentsSource(nameof(GenerateDataSets))]
public List<User> Hyperion_Deserialize(DataSet data)
{
using var ms = new MemoryStream(data.SerializedData.Hyperion);
ms.Position = 0;
return _hyperionSerializer.Deserialize<List<User>>(ms);
}
private byte[] DataConvert_Hyperion(List<User> users)
{
using var ms = new MemoryStream();
_hyperionSerializer.Serialize(users, ms);
return ms.ToArray();
}
}