-
Notifications
You must be signed in to change notification settings - Fork 0
Featrue/0.4.3.3 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ba91759
0.4.3.3 actor dictionary
teoadal 39759b5
ActorContext to sparse pages
teoadal f9394ff
ActorContext to sparse pages
teoadal eb4e0dc
ActorContext to sparse pages
teoadal caa3616
ActorContext to sparse pages
teoadal 510dc88
ActorContext to sparse pages
teoadal 09782e3
relations refactor
teoadal acd5ab8
relations refactor
teoadal 3082806
0.4.3.3 add more benchmarks
teoadal 1c30db3
cleanup
teoadal 7e09525
cleanup
teoadal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,31 +1,26 @@ | ||
| <Project> | ||
| <PropertyGroup> | ||
| <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
| <CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageVersion Include="MonoGame.Framework.DesktopGL" Version="3.8.4.1"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageVersion Include="DefaultEcs" Version="0.17.2"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageVersion Include="AutoFixture.Xunit2" Version="4.18.1"/> | ||
| <PackageVersion Include="BenchmarkDotNet" Version="0.15.8"/> | ||
| <PackageVersion Include="FluentAssertions" Version="8.8.0"/> | ||
| <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1"/> | ||
| <PackageVersion Include="Moq" Version="4.20.72"/> | ||
| <PackageVersion Include="xunit" Version="2.9.3"/> | ||
| <PackageVersion Include="JunitXml.TestLogger" Version="7.1.0"/> | ||
| <PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5"/> | ||
| <PackageVersion Include="coverlet.msbuild" Version="6.0.4"/> | ||
| <PackageVersion Include="coverlet.collector" Version="6.0.4"/> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
| <CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <PackageVersion Include="Friflo.Engine.ECS" Version="3.4.2" /> | ||
| <PackageVersion Include="DefaultEcs" Version="0.17.2" /> | ||
| <PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageVersion Include="MonoGame.Framework.DesktopGL" Version="3.8.4.1" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageVersion Include="AutoFixture.Xunit2" Version="4.18.1" /> | ||
| <PackageVersion Include="BenchmarkDotNet" Version="0.15.8" /> | ||
| <PackageVersion Include="FluentAssertions" Version="8.8.0" /> | ||
| <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" /> | ||
| <PackageVersion Include="Moq" Version="4.20.72" /> | ||
| <PackageVersion Include="xunit" Version="2.9.3" /> | ||
| <PackageVersion Include="JunitXml.TestLogger" Version="7.1.0" /> | ||
| <PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" /> | ||
| <PackageVersion Include="coverlet.msbuild" Version="6.0.4" /> | ||
| <PackageVersion Include="coverlet.collector" Version="6.0.4" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
194 changes: 194 additions & 0 deletions
194
src/Hexecs.Benchmarks/Actors/ActorCheckComponentExistsBenchmark.cs
This file contains hidden or 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,194 @@ | ||
| using System.Runtime.CompilerServices; | ||
| using Friflo.Engine.ECS; | ||
| using Hexecs.Benchmarks.Mocks.ActorComponents; | ||
| using Hexecs.Worlds; | ||
| using World = Hexecs.Worlds.World; | ||
|
|
||
| namespace Hexecs.Benchmarks.Actors; | ||
|
|
||
| // BenchmarkDotNet v0.15.8, Windows 11 (10.0.22621.4317/22H2/2022Update/SunValley2) | ||
| // Intel Xeon CPU E5-2697 v3 2.60GHz, 2 CPU, 56 logical and 28 physical cores | ||
| // .NET SDK 10.0.100 | ||
| // [Host] : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3 | ||
| // .NET 10.0 : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3 | ||
| // | ||
| // Job=.NET 10.0 Runtime=.NET 10.0 | ||
| // | ||
| // | Method | Count | Mean | Ratio | Allocated | Alloc Ratio | | ||
| // |----------------- |------- |----------:|------:|----------:|------------:| | ||
| // | Hexecs_Is | 10000 | 20.42 us | 0.96 | - | NA | | ||
| // | Hexecs_Has | 10000 | 21.19 us | 1.00 | - | NA | | ||
| // | Hexecs_Reference | 10000 | 24.30 us | 1.15 | - | NA | | ||
| // | FriFlo_Has | 10000 | 40.28 us | 1.90 | - | NA | | ||
| // | DefaultEcs_Has | 10000 | 73.24 us | 3.46 | - | NA | | ||
| // | | | | | | | | ||
| // | Hexecs_Is | 100000 | 204.98 us | 0.94 | - | NA | | ||
| // | Hexecs_Has | 100000 | 219.12 us | 1.00 | - | NA | | ||
| // | Hexecs_Reference | 100000 | 251.83 us | 1.15 | - | NA | | ||
| // | FriFlo_Has | 100000 | 409.48 us | 1.87 | - | NA | | ||
| // | DefaultEcs_Has | 100000 | 712.00 us | 3.25 | - | NA | | ||
| // | ||
| // ------------------------------------------------------------------------------------ | ||
| // | ||
| // BenchmarkDotNet v0.15.8, macOS Tahoe 26.2 (25C56) [Darwin 25.2.0] | ||
| // Apple M3 Max, 1 CPU, 16 logical and 16 physical cores | ||
| // .NET SDK 10.0.101 | ||
| // [Host] : .NET 10.0.1 (10.0.1, 10.0.125.57005), Arm64 RyuJIT armv8.0-a | ||
| // .NET 10.0 : .NET 10.0.1 (10.0.1, 10.0.125.57005), Arm64 RyuJIT armv8.0-a | ||
| // | ||
| // Job=.NET 10.0 Runtime=.NET 10.0 | ||
| // | ||
| // | Method | Mean | Ratio | Allocated | Alloc Ratio | | ||
| // |----------------- |----------:|------:|----------:|------------:| | ||
| // | Hexecs_Is | 12.76 us | 0.93 | - | NA | | ||
| // | Hexecs_Has | 13.79 us | 1.00 | - | NA | | ||
| // | Hexecs_Reference | 15.44 us | 1.12 | - | NA | | ||
| // | DefaultEcs_Has | 25.32 us | 1.84 | - | NA | | ||
| // | | | | | | | ||
| // | Hexecs_Is | 127.64 us | 0.92 | - | NA | | ||
| // | Hexecs_Has | 139.17 us | 1.00 | - | NA | | ||
| // | Hexecs_Reference | 155.12 us | 1.11 | - | NA | | ||
| // | DefaultEcs_Has | 255.36 us | 1.83 | - | NA | | ||
|
|
||
| [SimpleJob(RuntimeMoniker.Net10_0)] | ||
| [Orderer(SummaryOrderPolicy.FastestToSlowest)] | ||
| [MeanColumn, MemoryDiagnoser] | ||
| [HideColumns("Job", "Error", "StdDev", "Median", "RatioSD")] | ||
| [JsonExporterAttribute.Full] | ||
| [JsonExporterAttribute.FullCompressed] | ||
| [BenchmarkCategory("Actors")] | ||
| public class ActorCheckComponentExistsBenchmark | ||
| { | ||
| [Params(10_000, 100_000)] public int Count; | ||
|
|
||
| private ActorContext _context = null!; | ||
| private DefaultEcs.World _defaultWorld = null!; | ||
| private EntityStore _frifloWorld = null!; | ||
| private ArchetypeQuery _frifloAllEntitiesQuery = null!; | ||
| private World _world = null!; | ||
|
|
||
| [Benchmark(Baseline = true)] | ||
| public int Hexecs_Has() | ||
| { | ||
| var result = 0; | ||
|
|
||
| // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator | ||
| foreach (var actor in _context) | ||
| { | ||
| if (actor.Has<Speed>()) result++; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public int DefaultEcs_Has() | ||
| { | ||
| var result = 0; | ||
|
|
||
| // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator | ||
| foreach (var entity in _defaultWorld) | ||
| { | ||
| if (entity.Has<Speed>()) | ||
| { | ||
| result++; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public int FriFlo_Has() | ||
| { | ||
| var result = 0; | ||
|
|
||
| // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator | ||
| foreach (var entity in _frifloAllEntitiesQuery.Entities) | ||
| { | ||
| if (entity.HasComponent<Speed>()) | ||
| { | ||
| result++; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public int Hexecs_Is() | ||
| { | ||
| var result = 0; | ||
|
|
||
| // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator | ||
| foreach (var actor in _context) | ||
| { | ||
| if (actor.Is<Speed>(out _)) | ||
| { | ||
| result++; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public int Hexecs_Reference() | ||
| { | ||
| var result = 0; | ||
|
|
||
| // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator | ||
| foreach (var actor in _context) | ||
| { | ||
| ref var reference = ref actor.TryGetRef<Speed>(); | ||
| if (!Unsafe.IsNullRef(ref reference)) | ||
| { | ||
| result++; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| [GlobalCleanup] | ||
| public void Cleanup() | ||
| { | ||
| _defaultWorld.Dispose(); | ||
| _defaultWorld = null!; | ||
|
|
||
| _frifloWorld = null!; | ||
|
|
||
| _world.Dispose(); | ||
| _world = null!; | ||
| } | ||
|
|
||
| [GlobalSetup] | ||
| public void Setup() | ||
| { | ||
| _defaultWorld = new DefaultEcs.World(); | ||
| _frifloWorld = new EntityStore(); | ||
| _frifloAllEntitiesQuery = _frifloWorld.Query(); | ||
| _world = new WorldBuilder().Build(); | ||
| _context = _world.Actors; | ||
|
|
||
| for (var i = 0; i < Count; i++) | ||
| { | ||
| var actor = _context.CreateActor(); | ||
| actor.Add(new Attack()); | ||
| actor.Add(new Defence()); | ||
|
|
||
| var defaultEntity = _defaultWorld.CreateEntity(); | ||
| defaultEntity.Set<Attack>(); | ||
| defaultEntity.Set<Defence>(); | ||
|
|
||
| var frifloEntity = _frifloWorld.CreateEntity(new Attack(), new Defence()); | ||
|
|
||
| if (i % 10 != 0) continue; | ||
|
|
||
| actor.Add(new Speed()); | ||
|
|
||
| defaultEntity.Set<Speed>(); | ||
| frifloEntity.Add(new Speed()); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code should not contain multiple blank lines in a row.