From f820a0a7cc2e09f9126a0d46d3b1cde5ecacfa96 Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Thu, 7 Nov 2024 09:32:29 -0600 Subject: [PATCH] Non benchmark build fixes --- src/Rust.UiFramework.Benchmarks/Benchmarks.cs | 34 +++++++++++++------ src/Rust.UiFramework.Benchmarks/Program.cs | 2 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Rust.UiFramework.Benchmarks/Benchmarks.cs b/src/Rust.UiFramework.Benchmarks/Benchmarks.cs index f11f1ff..c3d770b 100644 --- a/src/Rust.UiFramework.Benchmarks/Benchmarks.cs +++ b/src/Rust.UiFramework.Benchmarks/Benchmarks.cs @@ -2,7 +2,6 @@ using BenchmarkDotNet.Attributes; using Facepunch; using Network; -using Oxide.Ext.UiFramework.Benchmarks; using Oxide.Ext.UiFramework.Builder.UI; using Oxide.Ext.UiFramework.Colors; using Oxide.Ext.UiFramework.Extensions; @@ -12,6 +11,10 @@ namespace Rust.UiFramework.Benchmarks; +#if BENCHMARKS + +using Oxide.Ext.UiFramework.Benchmarks; + [MemoryDiagnoser] public class Benchmarks { @@ -93,15 +96,22 @@ public void Setup() // return count; // } + [Benchmark(Baseline = true)] + public void UiFramework_Async() + { + UiBuilder builder = GetFrameworkBuilder(); + builder.AddUi(default(SendInfo)); + builder.Dispose(); + } + [Benchmark] - public byte[] Oxide_Full() + public void Oxide_Async() { CuiElementContainer builder = GetOxideContainer(); - string json = builder.ToJson(); - return Encoding.UTF8.GetBytes(json); + builder.AddUiAsync(_connection); } - - [Benchmark(Baseline = true)] + + //[Benchmark] public void UiFramework_Full() { UiBuilder builder = GetFrameworkBuilder(); @@ -113,13 +123,14 @@ public void UiFramework_Full() builder.Dispose(); } - //[Benchmark] - public void Oxide_Async() + [Benchmark] + public byte[] Oxide_Full() { CuiElementContainer builder = GetOxideContainer(); - builder.AddUiAsync(_connection); + string json = builder.ToJson(); + return Encoding.UTF8.GetBytes(json); } - + private CuiElementContainer GetOxideContainer() { CuiElementContainer container = new(); @@ -153,4 +164,5 @@ private UiBuilder GetFrameworkBuilder() return builder; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Rust.UiFramework.Benchmarks/Program.cs b/src/Rust.UiFramework.Benchmarks/Program.cs index bc37e3b..71d6ddc 100644 --- a/src/Rust.UiFramework.Benchmarks/Program.cs +++ b/src/Rust.UiFramework.Benchmarks/Program.cs @@ -9,9 +9,11 @@ class Program { static void Main(string[] args) { +#if BENCHMARKS ManualConfig config = DefaultConfig.Instance.AddJob(Job.Default .WithToolchain(InProcessEmitToolchain.Instance) .WithIterationCount(30)); BenchmarkRunner.Run(config, args); +#endif } } \ No newline at end of file