From 2a37322d78c9ce1d27cbc12e24dd918407a931e3 Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Mon, 3 Jun 2024 04:59:40 +0200 Subject: Update dependencies, some tests, other things --- .../LibMatrix.EventTypes.BasicTests.csproj | 4 -- .../LibMatrix.EventTypes.BasicTests/Program.cs | 77 +++++++++++++--------- .../LibMatrix.EventTypes.Benchmark.csproj | 24 +++++++ .../LibMatrix.EventTypes.Benchmark/Program.cs | 37 +++++++++++ .../LibMatrix.Utilities.Bot.csproj | 4 +- 5 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 Utilities/LibMatrix.EventTypes.Benchmark/LibMatrix.EventTypes.Benchmark.csproj create mode 100644 Utilities/LibMatrix.EventTypes.Benchmark/Program.cs (limited to 'Utilities') diff --git a/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj b/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj index b769cb7..e13103f 100644 --- a/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj +++ b/Utilities/LibMatrix.EventTypes.BasicTests/LibMatrix.EventTypes.BasicTests.csproj @@ -12,10 +12,6 @@ - - - - Always diff --git a/Utilities/LibMatrix.EventTypes.BasicTests/Program.cs b/Utilities/LibMatrix.EventTypes.BasicTests/Program.cs index 8c1e15a..d694c76 100644 --- a/Utilities/LibMatrix.EventTypes.BasicTests/Program.cs +++ b/Utilities/LibMatrix.EventTypes.BasicTests/Program.cs @@ -1,37 +1,50 @@ -using System.Text.Json; +// See https://aka.ms/new-console-template for more information + +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(); - -[ShortRunJob] -[MemoryDiagnoser] -public class Tests { - // public MatrixEventCollection Members = [ - // new MatrixEvent() { - // Content = new() { - // Membership = "join" - // } - // } - // ]; - - private static string eventJson = File.ReadAllText("test-event.json"); - private static MatrixEvent evt2 = JsonSerializer.Deserialize>(eventJson); - [Benchmark] - public void Deserialise() { - JsonSerializer.Deserialize>(eventJson); +using LibMatrix.EventTypes.Abstractions; +using LibMatrix.EventTypes.Spec; + +Console.WriteLine("Hello, World!"); + +MatrixEventCollection Members = [ + new MatrixEvent() { + Content = new() { + Membership = "join" + } + } +]; + +string eventJson = File.ReadAllText("test-event.json"); +MatrixEvent evt2 = JsonSerializer.Deserialize>(eventJson); + +JsonSerializer.Deserialize>(eventJson); + +evt2.ToJson(); +evt2.Content.Membership = "meow"; + +MatrixEventCollection collection = new(); +collection.Add(new MatrixEvent() { + Content = new RoomMembershipEventContent() { + Membership = "yes" } - [Benchmark] - public void Serialise() { - evt2.ToJson(); +}); +MatrixEventCollection collection4 = new(); +collection4.Add(new MatrixEvent() { + Content = new RoomMembershipEventContent() { + Membership = "yes" } - - [Benchmark] - public void Modify() { - evt2.Content.Membership = "meow"; +}); + +List> collection2 = new(); +collection2.Add(new MatrixEvent() { + Content = new RoomMembershipEventContent() { + Membership = "yes" } -} \ No newline at end of file +}); + +List collection3 = new(); +collection3.Add(new RoomMembershipEventContent() { + Membership = "yes" +}); \ No newline at end of file diff --git a/Utilities/LibMatrix.EventTypes.Benchmark/LibMatrix.EventTypes.Benchmark.csproj b/Utilities/LibMatrix.EventTypes.Benchmark/LibMatrix.EventTypes.Benchmark.csproj new file mode 100644 index 0000000..b769cb7 --- /dev/null +++ b/Utilities/LibMatrix.EventTypes.Benchmark/LibMatrix.EventTypes.Benchmark.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + + Always + + + 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(); + +[ShortRunJob] +[MemoryDiagnoser] +public class Tests { + // public MatrixEventCollection Members = [ + // new MatrixEvent() { + // Content = new() { + // Membership = "join" + // } + // } + // ]; + + private static string eventJson = File.ReadAllText("test-event.json"); + private static MatrixEvent evt2 = JsonSerializer.Deserialize>(eventJson); + [Benchmark] + public void Deserialise() { + JsonSerializer.Deserialize>(eventJson); + } + [Benchmark] + public void Serialise() { + evt2.ToJson(); + } + + [Benchmark] + public void Modify() { + evt2.Content.Membership = "meow"; + } +} \ No newline at end of file diff --git a/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj b/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj index 89ea5af..6e67373 100644 --- a/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj +++ b/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj @@ -12,9 +12,9 @@ - + - + -- cgit 1.4.1