diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2024-06-03 04:59:40 +0200 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2024-06-03 04:59:40 +0200 |
commit | 2a37322d78c9ce1d27cbc12e24dd918407a931e3 (patch) | |
tree | d3483edae6792bab1f10516b95779367220a2a8d /Utilities/LibMatrix.EventTypes.Benchmark/Program.cs | |
parent | Add all projects to sln (diff) | |
download | LibMatrix-2a37322d78c9ce1d27cbc12e24dd918407a931e3.tar.xz |
Update dependencies, some tests, other things dev/event-rewrite
Diffstat (limited to '')
-rw-r--r-- | Utilities/LibMatrix.EventTypes.Benchmark/Program.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Utilities/LibMatrix.EventTypes.Benchmark/Program.cs b/Utilities/LibMatrix.EventTypes.Benchmark/Program.cs new file mode 100644 index 0000000..512c066 --- /dev/null +++ b/Utilities/LibMatrix.EventTypes.Benchmark/Program.cs @@ -0,0 +1,37 @@ +using System.Text.Json; +using ArcaneLibs.Extensions; +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Running; +using LibMatrix.EventTypes; +using LibMatrix.EventTypes.Spec; + +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"; + } +} \ No newline at end of file |