Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
genaray committed Aug 12, 2024
1 parent d1fdb23 commit 1fc2968
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
24 changes: 22 additions & 2 deletions src/Arch.Benchmarks/Benchmark.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
using System.Numerics;
using Arch.Core;
using Arch.Core.Extensions;
using Arch.Core.Utils;

namespace Arch.Benchmarks;

public class Benchmark
{
private static void Main(string[] args)
{
/*
// NOTE: Can this be replaced with ManualConfig.CreateEmpty()?
#pragma warning disable HAA0101 // Array allocation for params parameter
var config = new ManualConfig()
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
.AddValidator(JitOptimizationsValidator.DontFailOnError)
.AddLogger(ConsoleLogger.Default)
.AddColumnProvider(DefaultColumnProviders.Instance);
#pragma warning restore HAA0101 // Array allocation for params parameter
#pragma warning restore HAA0101 // Array allocation for params parameter*/


var world = World.Create();
var signature = new Signature(typeof(int), typeof(long));
for (var index = 0; index <= 1; index++)
{
world.Create<int>();
}

var desc = new QueryDescription().WithAll<int>();
for (var index = 0; index <= 100000; index++)
{
world.Query(in desc, (ref int i) =>
{
});
}



// NOTE: Is `-- --job` a typo?
// Use: dotnet run -c Release --framework net7.0 -- --job short --filter *IterationBenchmark*
BenchmarkSwitcher.FromAssembly(typeof(Benchmark).Assembly).Run(args, config);
//BenchmarkSwitcher.FromAssembly(typeof(Benchmark).Assembly).Run(args, config);
}
}
2 changes: 1 addition & 1 deletion src/Arch.Benchmarks/QueryBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class QueryBenchmark
[Params(10000, 100000, 1000000)] public int Amount;

private static readonly ComponentType[] _group = { typeof(Transform), typeof(Velocity) };
private readonly QueryDescription _queryDescription = new() { All = _group };
private readonly QueryDescription _queryDescription = new(all: _group);

private static World? _world;

Expand Down
2 changes: 1 addition & 1 deletion src/Arch.Tests/Arch.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>

<!--<AllowUnsafeBlocks>true</AllowUnsafeBlocks>-->
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>Debug;Release;Release-Pure;Release-PureECS;Release-Events;Debug-PureECS;Debug-Events</Configurations>
<LangVersion>12</LangVersion>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<!--<TreatWarningsAsErrors>true</TreatWarningsAsErrors>-->
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Arch/Arch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Introduced breaking changes by renaming Group to Component and several other sma
<RepositoryType>git</RepositoryType>
<IsPackable>true</IsPackable>

<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Copyright>Apache2.0</Copyright>

Expand Down
27 changes: 20 additions & 7 deletions src/Arch/Core/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,26 +226,26 @@ public partial struct QueryDescription : IEquatable<QueryDescription>
/// An <see cref="Signature"/> of all components that an <see cref="Entity"/> should have mandatory.
/// <remarks>If the content of the array is subsequently changed, a <see cref="Rebuild"/> should be carried out.</remarks>
/// </summary>
public Signature All { get; private set; } = new();
public Signature All { get; private set; } = Signature.Null;

/// <summary>
/// An array of all components of which an <see cref="Entity"/> should have at least one.
/// <remarks>If the content of the array is subsequently changed, a <see cref="Rebuild"/> should be carried out.</remarks>
/// </summary>
public Signature Any { get; private set; } = new();
public Signature Any { get; private set; } = Signature.Null;

/// <summary>
/// An array of all components of which an <see cref="Entity"/> should not have any.
/// <remarks>If the content of the array is subsequently changed, a <see cref="Rebuild"/> should be carried out.</remarks>
/// </summary>
public Signature None { get; private set; } = new();
public Signature None { get; private set; } = Signature.Null;

/// <summary>
/// An array of all components that exactly match the structure of an <see cref="Entity"/>.
/// <see cref="Entity"/>'s with more or less components than those defined in the array are not addressed.
/// <remarks>If the content of the array is subsequently changed, a <see cref="Rebuild"/> should be carried out.</remarks>
/// </summary>
public Signature Exclusive { get; private set; } = new();
public Signature Exclusive { get; private set; } = Signature.Null;

/// <summary>
/// Initializes a new instance of the <see cref="QueryDescription"/> struct.
Expand All @@ -262,7 +262,7 @@ public QueryDescription()
/// <param name="any">An array of all components of which an <see cref="Entity"/> should have at least one.</param>
/// <param name="none">An array of all components of which an <see cref="Entity"/> should not have any.</param>
/// <param name="exclusive">All components that an <see cref="Entity"/> should have mandatory.</param>
public QueryDescription(ComponentType[]? all = null, ComponentType[]? any = null, ComponentType[]? none = null, ComponentType[]? exclusive = null)
public QueryDescription(Signature? all = null, Signature? any = null, Signature? none = null, Signature? exclusive = null)
{
All = all ?? All;
Any = any ?? Any;
Expand All @@ -273,9 +273,22 @@ public QueryDescription(ComponentType[]? all = null, ComponentType[]? any = null
_hashCode = GetHashCode();
}

public QueryDescription(Signature all) : this()
/// <summary>
/// Initializes a new instance of the <see cref="QueryDescription"/> struct.
/// </summary>
/// <param name="all">An array of all components that an <see cref="Entity"/> should have mandatory.</param>
/// <param name="any">An array of all components of which an <see cref="Entity"/> should have at least one.</param>
/// <param name="none">An array of all components of which an <see cref="Entity"/> should not have any.</param>
/// <param name="exclusive">All components that an <see cref="Entity"/> should have mandatory.</param>
public QueryDescription(ComponentType[]? all = null, ComponentType[]? any = null, ComponentType[]? none = null, ComponentType[]? exclusive = null)
{
All = all;
All = all ?? All;
Any = any ?? Any;
None = none ?? None;
Exclusive = exclusive ?? Exclusive;

_hashCode = -1;
_hashCode = GetHashCode();
}

/// <summary>
Expand Down

0 comments on commit 1fc2968

Please sign in to comment.