-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4658328
commit 48c9c87
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Flecs.NET.Core; | ||
|
||
namespace Flecs.NET.Benchmarks.Core | ||
{ | ||
public class AddRemoveTag | ||
{ | ||
[Params(100000)] | ||
public int EntityCount; | ||
|
||
[Params(1, 2, 16, 32)] | ||
public int TagCount; | ||
|
||
public World World; | ||
public Entity[] Entities; | ||
public Entity[] Tags; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
World = World.Create(); | ||
Entities = new Entity[EntityCount]; | ||
Tags = new Entity[TagCount]; | ||
|
||
for (int i = 0; i < EntityCount; i++) | ||
Entities[i] = World.Entity(); | ||
|
||
for (int i = 0; i < TagCount; i++) | ||
Tags[i] = World.Entity(); | ||
} | ||
|
||
[GlobalCleanup] | ||
public void Cleanup() | ||
{ | ||
World.Dispose(); | ||
} | ||
|
||
[Benchmark] | ||
public void Benchmark() | ||
{ | ||
for (int e = 0; e < EntityCount; e++) | ||
{ | ||
for (int tag = 0; tag < TagCount; tag++) | ||
Entities[e].Add(Tags[tag]); | ||
|
||
for (int tag = 0; tag < TagCount; tag++) | ||
Entities[e].Remove(Tags[tag]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<NoWarn>$(NoWarn);CS8618</NoWarn> | ||
</PropertyGroup> | ||
|
||
<Import Project="../Flecs.NET.Native/Flecs.NET.Native.targets"/> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.13.7"/> | ||
<ProjectReference Include="../Flecs.NET/Flecs.NET.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Running; | ||
|
||
[assembly: SimpleJob(runtimeMoniker: RuntimeMoniker.Net70, launchCount: 1, warmupCount: 5, iterationCount: 10)] | ||
[assembly: SimpleJob(runtimeMoniker: RuntimeMoniker.Net60, launchCount: 1, warmupCount: 5, iterationCount: 10)] | ||
[assembly: SimpleJob(runtimeMoniker: RuntimeMoniker.NetCoreApp31, launchCount: 1, warmupCount: 5, iterationCount: 10)] | ||
|
||
namespace Flecs.NET.Benchmarks | ||
{ | ||
public static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
BenchmarkSwitcher benchmark = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly); | ||
IConfig config = DefaultConfig.Instance.WithOptions(ConfigOptions.DisableOptimizationsValidator); | ||
|
||
if (args.Length == 0) | ||
benchmark.RunAll(config); | ||
else | ||
benchmark.Run(args, config); | ||
} | ||
} | ||
} |