Skip to content

Commit

Permalink
Ended up writing a lot of theoretical tests...
Browse files Browse the repository at this point in the history
  • Loading branch information
thygrrr committed Nov 11, 2024
1 parent 1b60cd4 commit 177addc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 30 deletions.
4 changes: 2 additions & 2 deletions fennecs.benchmarks/Conceptual/CostCentersBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public void Setup()
}

[Benchmark]
public int SingleArchetype()
public int FewArchetypesManyEntities()
{
var output = 0;
_streamOne.For((ref int value) => { output += value; });
return output;
}

[Benchmark]
public int ManyArchetypes()
public int ManyArchetypesFewEntities()
{
var output = 0;
_streamMany.For((ref int value) => { output += value; });
Expand Down
14 changes: 2 additions & 12 deletions fennecs.benchmarks/ECS/DorakuBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

namespace Benchmark.ECS;

[ShortRunJob]
//[TailCallDiagnoser]
[ThreadingDiagnoser]
[MemoryDiagnoser]
Expand Down Expand Up @@ -91,15 +90,15 @@ public void fennecs_For()


[BenchmarkCategory("fennecs")]
//[Benchmark(Description = "fennecs (For WL)")]
[Benchmark(Description = "fennecs (For WL)")]
public void fennecs_For_WL()
{
_query.For(Workload);
}


[BenchmarkCategory("fennecs")]
//[Benchmark(Description = $"fennecs (Job)")]
[Benchmark(Description = $"fennecs (Job)")]
public void fennecs_Job()
{
_query.Job(static delegate (ref Component1 c1, ref Component2 c2, ref Component3 c3) { c1.Value = c1.Value + c2.Value + c3.Value; });
Expand Down Expand Up @@ -318,15 +317,6 @@ private static void Raw_Workload_Tensor(Memory<Component1> c1V, Memory<Component
var c2I = MemoryMarshal.Cast<Component2, float>(c2V.Span);
var c3I = MemoryMarshal.Cast<Component3, float>(c3V.Span);

/*
var c1I = c1V.Span;
var c2I = c2V.Span;
var c3I = c3V.Span;
*/

//stackalloc float array
//Span<float> intermediate = stackalloc float[c1V.Length];

TensorPrimitives.Add(c2I, c1I, c1I);
TensorPrimitives.Add(c3I, c1I, c1I);
}
Expand Down
24 changes: 10 additions & 14 deletions fennecs.benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using Benchmark;
using Benchmark.Conceptual;
using Benchmark.ECS;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
Expand All @@ -11,20 +11,16 @@
var config = ManualConfig
.Create(DefaultConfig.Instance)
.WithOptions(ConfigOptions.JoinSummary)

.AddJob(
Job.ShortRun.WithId("Default")
.WithRuntime(CoreRuntime.Core90)
)

/*
.AddJob(
Job.ShortRun.WithId("Native")
.WithRuntime(NativeAotRuntime.Net90)
)
*/
.HideColumns("Job", "Error", "Median", "RatioSD");

var jobs = new List<Job>([
Job.ShortRun.WithId("Default").WithRuntime(CoreRuntime.Core90),
Job.ShortRun.WithId("Native").WithRuntime(NativeAotRuntime.Net90),
]);


foreach (var job in jobs) config.AddJob(job);

// Most relevant vectorization instruction sets, add other intrinsics as needed.
// These are exclusions you can use to TURN OFF specific benchmarks based on the
// supported feature of the system.
Expand All @@ -35,4 +31,4 @@
if (!AdvSimd.IsSupported) config.AddFilter(new CategoryExclusion(nameof(AdvSimd)));


BenchmarkRunner.Run<CostCentersBench>(config);
BenchmarkRunner.Run<DorakuBenchmarks>(config);
1 change: 1 addition & 0 deletions fennecs.tests/ArchetypeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using fennecs.storage;

namespace fennecs.tests;

Expand Down
22 changes: 22 additions & 0 deletions fennecs.tests/Conceptual/ReflectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace fennecs.tests.Conceptual;

using fennecs.storage;

public class ReflectionTests
{
[Fact]
public void MakeGenericType_is_Not_Unique()
{
var t1 = typeof(Storage<>).MakeGenericType(typeof(int));
var t2 = typeof(Storage<>).MakeGenericType(typeof(int));
Assert.Equal(t1, t2);
}

[Fact]
public void MakeGenericType_is_Same_As_Static()
{
var t1 = typeof(Storage<>).MakeGenericType(typeof(int));
var t2 = typeof(Storage<int>);
Assert.Equal(t1, t2);
}
}
4 changes: 3 additions & 1 deletion fennecs.tests/StorageTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace fennecs.tests;
using fennecs.storage;

namespace fennecs.tests;

public class StorageTests
{
Expand Down
1 change: 1 addition & 0 deletions fennecs/Archetype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Runtime.CompilerServices;
using fennecs.pools;
using fennecs.storage;

// ReSharper disable ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator

Expand Down
1 change: 1 addition & 0 deletions fennecs/Cross.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Buffers;
using System.Diagnostics;
using fennecs.pools;
using fennecs.storage;

namespace fennecs;

Expand Down
2 changes: 1 addition & 1 deletion fennecs/Storage.cs → fennecs/storage/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using fennecs.pools;

namespace fennecs;
namespace fennecs.storage;

/// <summary>
/// Generic Storage Interface (with boxing).
Expand Down

0 comments on commit 177addc

Please sign in to comment.