diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2024-06-01 19:02:28 +0200 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2024-06-01 19:03:05 +0200 |
commit | a129b321998614b20e4ebb8a7c1632553ebee981 (patch) | |
tree | f4e16f7b1bbeffc21e81f8749e4980994242ff19 /Utilities | |
parent | Event serialisation fix (diff) | |
download | LibMatrix-bak-a129b321998614b20e4ebb8a7c1632553ebee981.tar.xz |
Split event abstractions
Diffstat (limited to 'Utilities')
-rw-r--r-- | Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj | 24 | ||||
-rw-r--r-- | Utilities/LibMatrix.EventTypes.BasicTests/Program.cs | 37 |
2 files changed, 61 insertions, 0 deletions
diff --git a/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj b/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj new file mode 100644 index 0000000..b769cb7 --- /dev/null +++ b/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj @@ -0,0 +1,24 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\..\LibMatrix.EventTypes.Abstractions\LibMatrix.EventTypes.Abstractions.csproj" /> + <ProjectReference Include="..\..\LibMatrix.EventTypes.Spec\LibMatrix.EventTypes.Spec.csproj" /> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="BenchmarkDotNet" Version="0.13.12" /> + </ItemGroup> + + <ItemGroup> + <Content Include="*.json"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </ItemGroup> +</Project> diff --git a/Utilities/LibMatrix.EventTypes.BasicTests/Program.cs b/Utilities/LibMatrix.EventTypes.BasicTests/Program.cs new file mode 100644 index 0000000..8c1e15a --- /dev/null +++ b/Utilities/LibMatrix.EventTypes.BasicTests/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.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"; + } +} \ No newline at end of file |