Skip to content

Commit

Permalink
Non benchmark build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dassjosh committed Nov 7, 2024
1 parent 440ea26 commit f820a0a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/Rust.UiFramework.Benchmarks/Benchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +11,10 @@

namespace Rust.UiFramework.Benchmarks;

#if BENCHMARKS

using Oxide.Ext.UiFramework.Benchmarks;

[MemoryDiagnoser]
public class Benchmarks
{
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -153,4 +164,5 @@ private UiBuilder GetFrameworkBuilder()

return builder;
}
}
}
#endif
2 changes: 2 additions & 0 deletions src/Rust.UiFramework.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Benchmarks>(config, args);
#endif
}
}

0 comments on commit f820a0a

Please sign in to comment.