Skip to content

Commit

Permalink
Add AERCBenchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Jul 28, 2023
1 parent d2a094a commit e03511b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
42 changes: 42 additions & 0 deletions benchmarks/Entitas.Benchmarks/AERCBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#nullable disable

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Order;

// | Method | Mean | Error | StdDev | Rank | Allocated |
// |----------- |----------:|----------:|----------:|-----:|----------:|
// | UnsafeAERC | 1.153 ns | 0.0035 ns | 0.0033 ns | 1 | - |
// | SafeAERC | 18.992 ns | 0.0751 ns | 0.0665 ns | 2 | - |

namespace Entitas.Benchmarks
{
[MemoryDiagnoser]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[RankColumn]
public class AERCBenchmarks
{
SafeAERC _safeAerc;
UnsafeAERC _unsafeAerc;

[GlobalSetup]
public void GlobalSetup()
{
_safeAerc = new SafeAERC(null);
_unsafeAerc = new UnsafeAERC();
}

[Benchmark]
public void SafeAERC()
{
_safeAerc.Retain(this);
_safeAerc.Release(this);
}

[Benchmark]
public void UnsafeAERC()
{
_unsafeAerc.Retain(this);
_unsafeAerc.Release(this);
}
}
}
3 changes: 2 additions & 1 deletion benchmarks/Entitas.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
using Entitas.Benchmarks;

// BenchmarkRunner.Run<CreateComponentBenchmarks>();
BenchmarkRunner.Run<DelegateBenchmarks>();
// BenchmarkRunner.Run<DelegateBenchmarks>();
BenchmarkRunner.Run<AERCBenchmarks>();

0 comments on commit e03511b

Please sign in to comment.