blob: 8c1e15a891abc5af757af99996e3b04eb8c7f5bb (
plain) (
blame)
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
31
32
33
34
35
36
37
|
using System.Text.Json;
using ArcaneLibs.Extensions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using LibMatrix.EventTypes;
using LibMatrix.EventTypes.Events;
BenchmarkRunner.Run<Tests>();
[ShortRunJob]
[MemoryDiagnoser]
public class Tests {
// public MatrixEventCollection<MatrixEventContent> Members = [
// new MatrixEvent<RoomMembershipEventContent>() {
// Content = new() {
// Membership = "join"
// }
// }
// ];
private static string eventJson = File.ReadAllText("test-event.json");
private static MatrixEvent<RoomMembershipEventContent> evt2 = JsonSerializer.Deserialize<MatrixEvent<RoomMembershipEventContent>>(eventJson);
[Benchmark]
public void Deserialise() {
JsonSerializer.Deserialize<MatrixEvent<RoomMembershipEventContent>>(eventJson);
}
[Benchmark]
public void Serialise() {
evt2.ToJson();
}
[Benchmark]
public void Modify() {
evt2.Content.Membership = "meow";
}
}
|