EasyEcs

Performance guide

How fast EasyEcs is and how to keep your code fast: measured server ticks, the cost of each iteration API, a checklist and every BenchmarkDotNet result.

EasyEcs is built for a server tick that runs every few milliseconds for months: the regular way of writing a system is already a generated, inlined struct job, and a busy world allocates nothing per tick. This page shows what that costs on a real tick, which API to pick for each loop, the rewrites that pay when a system shows up in your timings, and every benchmark behind those numbers. How the library gets there is on Why EasyEcs is fast.

Save 10,000 entities and load them back, vs DefaultEcs

30×faster
EasyEcs 146 μs, DefaultEcs 4.33 ms
  • EasyEcs146 μs
  • DefaultEcs4.33 ms

One server tick

1.72ms
100,000 entities in one world

Four worlds, one thread each

924μs
4 × 25,000 entities

Allocated per tick

0B
after warm-up; the unit tests fail the build otherwise

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

The headline ticks

WorldSimulationBenchmark is one tick of a busy MMO-style world, not a toy loop: 30% players, 70% NPCs and projectiles on top. One tick runs movement (skipping Stunned and Dead), an area-of-interest grid, combat that adds Burning and Stunned at random, status expiry that removes them, death (a Dead tag and a statistics singleton), respawn (dead NPCs replaced, dead players revived in place), and projectiles spawned by about 5% of the players and expired after 20 ticks. Setup checks that the world is busy: hits, deaths, spawns and grid changes all happen.

BenchmarkWhat it runsTime per tickAllocated per tick
WorldSimulationBenchmarkone world, 100,000 entities1.72 ms0 B
MultiWorldBenchmarkfour worlds of 25,000, one thread each924 μs0 B
BattleServerBenchmarkthe battle server: every feature at once2.97 ms0 B

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

The four worlds of MultiWorldBenchmark are the layout recommended for a server: one world per map or zone, each owned by one long-lived thread.

Against other libraries

The same work ported to Friflo.Engine.ECS, Arch and DefaultEcs, each library its own idiomatic way, with identical results checked in setup: EasyEcs is faster in 24 of 37 head-to-head benchmarks and within the measurement error in 11 more. These are its biggest leads over the fastest other library:

Feature by feature: how many times longer the next-fastest library takes

Each comparison does the same work in Friflo.Engine.ECS, Arch and DefaultEcs, each library's own idiomatic way, with identical results checked in setup. A bar is the fastest other library's time over EasyEcs' time (log scale).

Save 10,000 entities and load them back30× · DefaultEcsAdd a component to 100,000 entities by query, then remove it15× · ArchSpawn 10,000 entities beside 100,000, then destroy them2.75× · FrifloQuery 100,000 players by value: a rating range, zone sums2.49× · FrifloCreate 1,000 parent-child squads, destroy them in cascade2.35× · FrifloCount 100 inventories through an index (1 item traded)1.97× · DefaultEcsAdd a status component to 5% of 100,000 entities, then remove it1.94× · FrifloFind the 10 of 100,000 entities written this tick1.91× · Arch1×2×5×10×20×Its time ÷ EasyEcs' time (log scale)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
What is measuredEasyEcsNext fastestvs EasyEcs
Save 10,000 entities and load them back146 μsDefaultEcs 4.33 ms30×
Add a component to 100,000 entities by query, then remove it78.7 μsArch 1.21 ms15×
Spawn 10,000 entities beside 100,000, then destroy them138 μsFriflo.Engine.ECS 380 μs2.75×
Query 100,000 players by value: a rating range, zone sums127 μsFriflo.Engine.ECS 317 μs2.49×
Create 1,000 parent-child squads, destroy them in cascade452 μsFriflo.Engine.ECS 1.06 ms2.35×
Count 100 inventories through an index (1 item traded)425 nsDefaultEcs 838 ns1.97×
Add a status component to 5% of 100,000 entities, then remove it517 μsFriflo.Engine.ECS 1.00 ms1.94×
Find the 10 of 100,000 entities written this tick507 nsArch 966 ns1.91×

The full server tick is closer, because most of a tick is iteration over dense columns, bound by memory more than by the library:

One server tick of 100,000 entities: EasyEcs vs Friflo, Arch and DefaultEcs

The same simulation ported to each library's fast path, with identical results checked in setup. Shorter is faster; the badge is the time relative to EasyEcs and the memory allocated per tick.

  • EasyEcs
  • Other libraries
EasyEcs 4.60 B per tick1.68 msFriflo.Engine.ECS 3.61.08× · 0 B per tick1.83 msArch 2.13.4× · 535 KB per tick5.76 msDefaultEcs 0.173.7× · 60.9 KB per tick6.24 ms0.00 ns1.00 ms2.00 ms3.00 ms4.00 ms5.00 ms6.00 msTime per tick

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryTimevs EasyEcsAllocated
EasyEcs 4.61.68 ms1.00×0 B
Friflo.Engine.ECS 3.61.83 ms1.08×0 B
Arch 2.15.76 ms3.4×535 KB
DefaultEcs 0.176.24 ms3.7×60.9 KB

Every comparison, sorted by lead, with the ones where another library is faster and why: Comparison.

Creating entities in a fresh world

A server creates most of its entities in a world that has never held any: at start-up, or when it opens a map or a match. ColdCreateComparison measures that moment: 100,000 entities of one, two or three components created in a new world of each library, a new world for every call, three ways:

  • PerEntity: one CreateEntity per entity, nothing reserved.
  • PerEntity_Reserved: the same loop after reserving room for all of them: world.EnsureCapacity<T1, …, Tn>(n) in EasyEcs, EnsureCapacity on the store and the archetype in Friflo, EnsureCapacity with the signature in Arch. DefaultEcs has no reservation per component set.
  • Bulk: one world.CreateEntities(span, values) call. Only EasyEcs runs this case; the comparisons count each other library's fastest way against it.

Create 100,000 entities of one component in a fresh world

Without and with a reservation, and in one call. Shorter is faster.

  • EasyEcs
  • Friflo.Engine.ECS
  • Arch
  • DefaultEcs
PerEntityFriflo.Engine.ECS 2.56×, Arch 0.63×, DefaultEcs 2.19×5.99 ms · 6.97 MB15.3 ms · 7.99 MB3.76 ms · 4.00 MB13.1 ms · 11.1 MBPerEntity_ReservedFriflo.Engine.ECS 5.8×, Arch 1.78×1.94 ms · 2.67 MB11.3 ms · 3.29 MB3.45 ms · 3.85 MBBulk2.65 ms · 4.20 MB0.00 ns2.00 ms4.00 ms6.00 ms8.00 ms10.0 ms12.0 ms14.0 ms16.0 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsPerEntity5.99 ms1.00×6.97 MB
Friflo.Engine.ECSPerEntity15.3 ms2.56×7.99 MB
ArchPerEntity3.76 ms0.63×4.00 MB
DefaultEcsPerEntity13.1 ms2.19×11.1 MB
EasyEcsPerEntity_Reserved1.94 ms1.00×2.67 MB
Friflo.Engine.ECSPerEntity_Reserved11.3 ms5.8×3.29 MB
ArchPerEntity_Reserved3.45 ms1.78×3.85 MB
EasyEcsBulk2.65 ms1.00×4.20 MB

Pre-sized or in one call, EasyEcs is the fastest of the four. With three components, the reserved loop takes 2.60 ms and one CreateEntities call 2.71 ms; Arch, the next fastest, takes 4.21 ms reserved, 1.62× as long.

One by one with nothing reserved, Arch is faster. EasyEcs takes 7.13 ms, 1.50× as long as Arch's 4.77 ms. Without a reservation, a fresh table grows by doubling, and so does the entity storage. Their arrays past 85,000 bytes go to the large object heap, and once the allocations there pass the runtime's budget, .NET starts a full collection: one per new world in this benchmark, and most of the difference. Arch keeps entities in chunks of 16 KB, small objects that never reach that heap. Friflo and DefaultEcs pay the collection too and stay slower than EasyEcs.

A reservation sizes the table and the entity storage once and puts the entity records on the pinned object heap, so the run stays under both budgets and no collection starts (D28); the loop without it takes 2.75× as long. So when you know how many entities a world is about to get, say so:

// The table of exactly these components, sized for the whole start-up
world.EnsureCapacity<Position, Velocity, Health>(100_000);
for (int i = 0; i < 100_000; i++)
    world.CreateEntity(new Position(i, 0), new Velocity(1, 0), new Health(100));

Entities that start with the same values can also come in one call, which sizes the table from the span and hands you the handles:

var garrison = new Entity[100_000];
world.CreateEntities(garrison, new Position(0, 0), new Velocity(0, 0), new Health(100));

Only the first fill of a world pays the growth. A world that already has the room creates and destroys at full speed: CreateDestroy in the single operations.

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Choosing an iteration API

Every API walks the same tables front to back. What differs is the bookkeeping around each row: a delegate call, an enumerator, a structural-change check. Pick the first row that fits:

NeedUseMeasured
The per-entity logic of a systema [ForEach] method0.91 ns per entity, against 1.28 ns for two plain arrays
Arithmetic over many rowsa batch [ForEach] method (spans), vectorized69.5 μs instead of 253 μs per-entity (100,000 entities)
Heavy per-entity work[ForEach(Parallel = true)]884 μs instead of 1.68 ms (100,000 entities, 4 cores)
A loop outside systems, every ticka static [ForEach] method run through its entry point, or a struct job (world.ForEach)33.7 μs, against 145 μs for a Query loop
A loop in a tool, a test or a request handlerforeach (var item in world.Query<...>())30.5 μs, against 12.9 μs for a struct job (10,000 entities)
"How many?" / "Is there any?"world.Count / world.Any1.20 μs for 100,000 rows whose bits must be tested
The few rows written since the last runITrackChanges + [Changed<T>]525 ns instead of 38.6 μs (10 of 100,000 written)
The entities that lost a componentITrackChanges + [Removed<T>]830 ns (10 of 100,000 removed)
Entities by valuea value indexsee IndexBenchmark below

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

[ForEach] beats two plain arrays because its columns start on a 64-byte boundary: a row of a power-of-two-sized component never straddles two cache lines. MicroBenchmarks.ForEachSystemWrite runs on a world with one table; the other iteration rows of MicroBenchmarks use a world where every other entity also has Health (two tables), so compare APIs within one world, not across them.

Regular code and the fastest code

The regular way is right for most systems: short, and already a generated struct job. When a system shows up in WorldOptions.MeasureSystems timings (measuring systems), these rewrites are what the benchmarks measure:

RegularFastestMeasured
A per-entity [ForEach] doing arithmetic with branchesA batch method vectorized with Vector<T>, branches as masks253 μs → 69.5 μs
foreach (var item in world.Query<...>()) in a hot ad-hoc loopA struct job with world.ForEach30.5 μs → 12.9 μs
A bool flag tested in every rowA tag with [With<T>] / [Without<T>]rows without the tag skipped 64 at a time; toggling flips a bit
Scanning every row for the few that changedITrackChanges + [Changed<T>]38.6 μs → 525 ns
CreateEntity / Destroy in a loopCreateEntities / DestroyEntities, Instantiate(prefab, span)334 μs → 157 μs
Setting a component on every entity one by oneworld.SetAll / RemoveAll1.68 ms → 87.9 μs
One method taking Maybe<T>Two methods split by [With<T>] / [Without<T>]130 μs → 41.8 μs
A QueryFilter built at the callA static readonly filter74.8 ns → 21.6 ns per call
Heavy per-entity work on one thread[ForEach(Parallel = true)]1.68 ms → 884 μs

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Arithmetic over many rows: vectorize a batch method

The JIT does not vectorize this loop, and the bounce branches mispredict on many rows. The regular system:

BounceSystem.cs
public class BounceSystem : EcsSystem
{
    [ForEach, Without<Dead>]
    static void Move(ref Position p, ref Velocity v)
    {
        p = new Position(p.X + v.X, p.Y + v.Y);
        if (p.X < 0 || p.X > 4096) v = v with { X = -v.X };
        if (p.Y < 0 || p.Y > 4096) v = v with { Y = -v.Y };
    }
}

The fastest one takes spans (runs of consecutive rows; a table whose rows all match is one call), reads the two-float components as one float span (X, Y, X, Y, ...) so every lane of a Vector<float> is one coordinate, and turns the branches into a mask:

BounceSimdSystem.cs
using System.Numerics;
using System.Runtime.InteropServices;

public class BounceSimdSystem : EcsSystem
{
    [ForEach, Without<Dead>]
    static void Move(Span<Position> positions, Span<Velocity> velocities)
    {
        var p = MemoryMarshal.Cast<Position, float>(positions);
        var v = MemoryMarshal.Cast<Velocity, float>(velocities);
        var max = new Vector<float>(4096f);
        int i = 0;
        for (; i <= p.Length - Vector<float>.Count; i += Vector<float>.Count)
        {
            var velocity = new Vector<float>(v[i..]);
            var position = new Vector<float>(p[i..]) + velocity;
            var outside = Vector.LessThan(position, Vector<float>.Zero) | Vector.GreaterThan(position, max);
            position.CopyTo(p[i..]);
            Vector.ConditionalSelect(outside, -velocity, velocity).CopyTo(v[i..]);
        }

        for (; i < p.Length; i++) // the rows left over
        {
            p[i] += v[i];
            if (p[i] < 0 || p[i] > 4096) v[i] = -v[i];
        }
    }
}

The cast is valid because the components hold only floats (no padding, no references), and unmanaged columns start on a 64-byte boundary, so vector loads stay aligned. A batch method makes no structural change and reads entities through an EntitySpan parameter only where it needs them. A scalar loop over spans gains little over the per-entity method: write one to vectorize it.

Movement over 100,000 entities: per entity and vectorized

  • EasyEcs
  • Friflo.Engine.ECS
Iterate2Friflo.Engine.ECS 1.02×253 μs · 0 B257 μs · 0 BIterate2SimdFriflo.Engine.ECS 1.16×69.5 μs · 0 B80.7 μs · 0 B0.00 ns50.0 μs100 μs150 μs200 μs250 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsIterate2253 μs1.00×0 B
Friflo.Engine.ECSIterate2257 μs1.02×0 B
EasyEcsIterate2Simd69.5 μs1.00×0 B
Friflo.Engine.ECSIterate2Simd80.7 μs1.16×0 B

Ad-hoc loops: a struct job

world.Query is the convenient loop for tools and request handlers. For a loop that runs every tick outside a system, write a struct job: world.ForEach specializes and inlines it per table. Mark it INoStructuralChanges and declare its Writes (what a job declares).

EnergyJob.cs
public struct EnergyJob : IForEach<Velocity>, INoStructuralChanges   // no structural change: the lean loop
{
    public float Total;   // a value field stays in a register during the pass and is copied back once

    public static int Writes => 0;   // reads only: no row counts as changed

    public void Execute(ref Velocity v) => Total += v.X * v.X + v.Y * v.Y;
}
var job = new EnergyJob();
world.ForEach<Velocity, EnergyJob>(ref job);
float energy = job.Total;

Declare the job a ref struct when it must hold a ref or a Span (an output buffer, a caller's array). ForEach, ForEachEntity and ForEachBatch accept ref struct jobs; the *Parallel calls do not, because each thread gets its own copy of the job. For a total, a value field is faster than a ref field: a write through a ref goes to memory on every row.

CollectJob.cs
public ref struct CollectJob : IForEach<Position>, INoStructuralChanges
{
    public Span<float> Xs;   // the caller's buffer, at least as long as the matching rows
    public int Count;

    public static int Writes => 0;

    public void Execute(ref Position p) => Xs[Count++] = p.X;
}

A static [ForEach] method outside a system does the same with less code: the generator writes the job and an entry point that takes the world (RunnerBenchmark measures both).

Census.cs
public static class Census
{
    [ForEach, Without<Dead>]
    static void CountWounded(in Health health, ref int wounded)
    {
        if (health.Value < 50) wounded++;
    }
}
int wounded = 0;
Census.CountWounded(world, ref wounded);   // generated entry point: the job runs once

States: tags, not flags

A flag costs a load and a branch in every row of every system that checks it. A tag is a filter: rows without it are skipped 64 at a time, and adding or removing it flips a presence bit while the entity keeps its row.

Stun.cs
public record struct Unit(int Hp, bool Stunned) : IComponent;   // regular: every system tests the flag

public class StunnedFlagSystem : EcsSystem
{
    [ForEach]
    static void Act(ref Unit unit)
    {
        if (unit.Stunned) return;
        unit.Hp++;
    }
}

public class StunnedTagSystem : EcsSystem   // fastest: the filter does the test
{
    [ForEach, Without<Stunned>]
    static void Act(ref Health hp) => hp = hp with { Value = hp.Value + 1 };
}

Toggling a status is where this shows against other archetype libraries: EasyEcs flips a bit, Friflo moves the entity to another archetype and back.

Stun 5% of 100,000 fighters, then recover them

  • EasyEcs
  • Friflo.Engine.ECS
ToggleFriflo.Engine.ECS 1.94×517 μs · 0 B1.00 ms · 0 B0.00 ns200 μs400 μs600 μs800 μs1.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsToggle517 μs1.00×0 B
Friflo.Engine.ECSToggle1.00 ms1.94×0 B

The few rows that changed: [Changed<T>]

A replication or persistence system that scans every row pays for the rows nobody wrote. Mark the component ITrackChanges and filter with [Changed<T>]: unwritten tables, 4,096-row blocks and 64-row words are skipped. Take the component by in, so the visit does not count as a write.

ShieldReplicationSystem.cs
public record struct Shield(int Value) : IComponent, ITrackChanges;
public record struct ShieldReplica(int Value) : IComponent;

public class ShieldReplicationSystem : EcsSystem
{
    [ForEach, Changed<Shield>]
    static void Send(in Shield shield, ref ShieldReplica replica) => replica = new ShieldReplica(shield.Value);
}

It pays when few rows are written, or when the written rows sit close together:

Rows written of 100,000[Changed<T>]Every row
10525 ns38.6 μs
1,000, spread 97 rows apart38.9 μs67.2 μs

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

When writes land in most 64-row words, nothing is skipped and testing the change ticks costs about what reading the column does. For a cheap check over a column that most rows write every tick (a death check on Health), a plain scan is as fast and simpler.

What went away: [Removed<T>]

Replicating a removal (a fire that went out) with a marker tag costs a structural change per removal and a pass over the tags; comparing every row with what clients last received costs a scan. A tracked component's removal already stamps its row, so [Removed<T>] visits only the entities that lost it, with the same skipping as [Changed<T>]:

ShieldLossSystem.cs
public class ShieldLossSystem : EcsSystem
{
    [ForEach, Removed<Shield>]                       // Shield : ITrackChanges (above)
    static void Send(ref ShieldReplica replica) => replica = new ShieldReplica(0);
}

Find the 10 of 100,000 entities that lost a buff

  • EasyEcs
  • Other libraries
EasyEcs: Removed0 B allocated830 nsDefaultEcs: WhenRemoved48× · 0 B allocated39.6 μsFriflo.Engine.ECS: Event0.84× · 0 B allocated697 nsArch: LostTag2.18× · 0 B allocated1.81 μs0.00 ns5.00 μs10.0 μs15.0 μs20.0 μs25.0 μs30.0 μs35.0 μs40.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsRemoved830 ns1.00×0 B
DefaultEcsWhenRemoved39.6 μs48×0 B
Friflo.Engine.ECSEvent697 ns0.84×0 B
ArchLostTag1.81 μs2.18×0 B

The entity only where the row needs it

An Entity parameter builds a handle for every row, even when only a rare branch uses it, and it makes the system run alone in a parallel stage. When the entities a system acts on can be told by a component, filter on it ([With<Dead>]) instead of testing every row. A batch method that needs the entity of a few rows takes an EntitySpan, which builds a handle only for the rows it indexes.

A pass over 100,000 entities that rarely needs the entity

  • EasyEcs
  • Friflo.Engine.ECS
EntityFriflo.Engine.ECS 1.37×49.0 μs · 0 B67.2 μs · 0 BEntityBatchFriflo.Engine.ECS 0.96×38.5 μs · 0 B37.0 μs · 0 B0.00 ns10.0 μs20.0 μs30.0 μs40.0 μs50.0 μs60.0 μs70.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsEntity49.0 μs1.00×0 B
Friflo.Engine.ECSEntity67.2 μs1.37×0 B
EasyEcsEntityBatch38.5 μs1.00×0 B
Friflo.Engine.ECSEntityBatch37.0 μs0.96×0 B

Waves of entities: bulk calls

private static readonly Prefab Goblin = new Prefab().SetPosition(0, 0).SetHealth(30);
var wave = new Entity[1_000];
world.CreateEntities(wave, new Position(0, 0), new Velocity(1, 0));   // one pass through the structural gate
world.Instantiate(Goblin, wave);                                      // a wave of a prefab, the same way
int removed = world.DestroyEntities<Dead>();                          // every dead entity, one pass
int lifted = world.RemoveAll<Stunned>();                              // every stun lifted, whole words of rows

A prefab built once (static readonly) costs one row copy per instance; the world finds its target table once and caches it. entity.Set(a, b) and entity.Remove<A, B>() change several components in one call: shorter to write, and the same cost as one call per component, since the second move takes a cached transition (D29).

Do

The checklist for code that runs every tick. Find the system worth the effort first: WorldOptions.MeasureSystems times every system run.

  • Mutate through refs: ref var hp = ref item.Component1;, ref var hp = ref entity.Get<Health>();.
  • Spawn with every component at once: world.CreateEntity(a, b, c) places the entity in its final table; world.Instantiate(prefab) for a kind defined once. entity.Set(a, b) / entity.Remove<A, B>() change several components in one call: shorter, with the same cost as one call each.
  • Read with in, write with ref: in parameters, entity.Read<T>() or the generated property read; ref parameters and entity.Get<T>() write. A ref access counts as a write of a tracked component, and a Query loop counts every row it visits; a struct job that only reads declares static int Writes => 0.
  • Keep [ForEach] methods that make no structural change static, without a World parameter and with read-only use of their Entity: the generator marks their job INoStructuralChanges, which skips the per-row bookkeeping. Mark hand-written jobs the same way.
  • Take singletons as [ForEach] parameters (resolved once per pass), or keep a SingletonRef<T> outside systems (no lookup per access).
  • Give systems a cadence: UpdateInterval, or a system group updated when needed (Update<TGroup>()), instead of a counter checked in the method.
  • Keep components small (a few fields, well under 64 bytes) and split rarely used data into its own component: iteration loads only the columns it reads.
  • Vectorize arithmetic in batch methods, use bulk calls for waves, tags for states, [Changed<T>] for what changed and [Removed<T>] for what went away (above).
  • Ask world.Count / world.Any instead of looping to count or to find one match.
  • Reserve room in a DynamicBuffer<T> whose size is known (EnsureCapacity), and pre-size the world with WorldOptions.InitialEntityCapacity or world.EnsureEntityCapacity(n), and a table before creating its entities one by one with world.EnsureCapacity<T1, …, Tn>(n).
  • Keep QueryFilters in static readonly fields (the generator does this for [ForEach]).
  • Look entities up with a value index (IIndexed<TKey>) instead of a dictionary kept in sync by hand, and write an indexed component only when its key changes.
  • Run one world per thread on servers, for example one per map or zone.

Don't

  • Don't modify a copy of a component and forget to write it back.
  • Don't keep refs across await or in fields: keep the Entity handle.
  • Don't store raw entity indexes: ids are recycled; store an EntityId (index and version).
  • Don't write lambdas that capture locals in methods that run every update: the closure is allocated at method entry even when its branch is not taken. AllocationTests caught exactly this in World.Update (EECS028).
  • Don't use LINQ, params object[] or string formatting in per-update code (EECS028).
  • Don't take an Entity or a singleton parameter a method does not need: the loop loads it for every row (EECS026).
  • Don't take a tracked component by ref when the method only reads it: every visited row then counts as changed (EECS025).
  • Don't look up the visited entity's components or a singleton inside a [ForEach] method: a parameter resolves them once per table (EECS027).
  • Don't make a [ForEach] method an instance method when it uses nothing of its system: it then runs alone and pays the checks of a structural change (EECS029).
  • Don't loop over a query to change, count or test entities one by one: SetAll, DestroyEntities, Count, Any and filters do it per table (EECS030, EECS032).
  • Don't use a value index, or destroy entities, from another thread: the index follows those changes on the owner thread and is not synchronized.

Pitfalls

MistakeWhat happensCaught by
A batch method that also takes a per-entity parameterIt cannot receive runs of rowsEECS009
A structural change in a static [ForEach] method without Entity or WorldThe method promises no structural change, and its lean loop relies on itEECS013
A parallel method that writes a singleton or changes structureData races between the threadsEECS010
An Entity stored in a componentThe column holds references: no longer pinned, scanned by the GCEECS017 (warning)
Writing an indexed component through a refThe index cannot see the new keyEECS015
A computed UpdateIntervalRead every updateEECS018 (warning)
A ref parameter that only reads a tracked componentEvery visited row counts as changedEECS025 (warning, code fix: in)
A closure or LINQ in per-update codeGarbage every tickEECS028 (warning), and AllocationTests-style checks in your own tests
A lookup through the visited Entity in a [ForEach] methodA search per rowEECS027 (warning)
A structural change entity by entity over a queryOne row moved per callEECS030 (warning, code fix: the bulk call)
Filling a fresh world one entity at a time, nothing reservedDoubling arrays on the large object heap start a full collection (above)EECS031 (warning, code fix: CreateEntities or EnsureCapacity<T1, …, Tn>(n))

What is covered

Every feature has unit tests (tests/EasyEcs.UnitTest), a BenchmarkDotNet benchmark and, where a peer library has the feature, a head-to-head comparison that checks every library computes the same result before it measures.

FeatureTestsBenchmarkAgainst other libraries
A whole server tickBattleServerTestsWorldSimulationBenchmark, MultiWorldBenchmark, BattleServerBenchmarkEcsComparisonBenchmark
[ForEach], struct jobs, QueryForEachSystemTests, QueryTests, RunnerTestsMicroBenchmarks, RunnerBenchmark, CallSiteBenchmarkOperationBenchmark
Structural changes, presence bitsEntityTests, ComponentTests, PresenceTestsMicroBenchmarks (Churn, ToggleComponent), SparseBenchmark, CountBenchmarkStructuralChangeComparison
Bulk changes and spawnsBulkTestsBulkBenchmark, MicroBenchmarks.ChurnBatchBulkChangeComparison, BulkSpawnComparison
Prefabs and clonesInstantiateTestsPrefabBenchmarkOperationBenchmark (Instantiate)
Change trackingChangedTestsChangeTrackingBenchmarkChangeTrackingComparison
Removal detectionRemovedTestsBattleServerBenchmarkRemovalComparison
DisablingDisableTestsBulkBenchmark (DisableAll)DisableComparison
Value indexes, ordered indexesIndexTests, OrderedIndexTestsIndexBenchmark, OrderedIndexBenchmarkIndexComparison, ValueQueryComparison
RelationsRelationTests, TargetPolicyTestsRelationBenchmarkRelationComparison
HierarchyHierarchyTestsHierarchyBenchmarkHierarchyComparison
GroupsGroupTestsGroupBenchmarkValueQueryComparison
SingletonsSingletonTestsMicroBenchmarks.SingletonAccessOperationBenchmark (Singleton)
Optional components (Maybe<T>)ForEachSystemTestsMaybeBenchmark—
Dynamic buffersDynamicBufferTestsDynamicBufferBenchmark—
Cleanup componentsCleanupTestsCleanupBenchmark—
System ordering and groupsSystemTestsOrderingBenchmark—
Parallel systems and [ForEach(Parallel = true)]ParallelTests, ConcurrencyTestsParallelSystemsBenchmark, ParallelForEachBenchmarkParallelSystemsComparison, ParallelQueryComparison
SnapshotsSnapshotTestsSnapshotBenchmark (Capture, Restore)—
SavesSerializationTestsSnapshotBenchmark (Save, Load)SaveComparison
Moving entities between worldsMoveTestsMigrationBenchmark—
Unloading a plugin's typesUnloadTestsUnloadBenchmark—
IntrospectionIntrospectionTestsIntrospectionBenchmark—
Generic systemsGenericTests——
Generator, analyzer, code fixesGeneratorTests, CodeFixTests——
Zero allocationAllocationTests (0 B budget on every test run)the Allocated column of every benchmarkevery comparison

Benchmarks

Every class of benchmarks/EasyEcs.Benchmark, from one full run. Bars are EasyEcs; the ratio is against the class's baseline, the first way of doing the job. The comparisons with other libraries are on the comparison page.

Server ticks

WorldSimulationBenchmark and MultiWorldBenchmark are the headline world above. BattleServerBenchmark is one tick of the battle server (BattleServer.cs), which uses every feature: a parallel [ForEach], two systems that run at once, statuses added and removed mid-pass, WithAny, deaths, respawns and projectiles, a value index, a relation, prefabs, an update interval, per-system timings and replication every third tick with [Changed<T>] and [Removed<T>]. BattleServerTests checks the same world.

CaseEntitiesMeanvs baselineAllocated
Tick10000158 μs—0 B
Tick1000001.72 ms—0 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.
CaseMeanvs baselineAllocated
TickAllWorlds924 μs—0 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.
CaseMeanvs baselineAllocated
Tick2.97 ms—0 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Single operations

MicroBenchmarks isolate one operation each, over 10,000 entities. RawArrayWrite is the floor without an ECS: two plain arrays. HandleAccess, TryGetEntity, TrackedHandleWrite, SingletonAccess and CountAndAny repeat their call 1,000 times. CreateAddDestroy builds a fresh world each time, so its allocations are the new world and its growth.

MicroBenchmarks: one operation each, 10,000 entities

CreateAddDestroy82× · 1.52 MB allocated1.03 msChurn26× · 0 B allocated334 μsChurnBatch12× · 0 B allocated157 μsRemoveMany4.0× · 0 B allocated51.0 μsToggleComponent13× · 0 B allocated158 μsQueryIterate2.41× · 0 B allocated30.5 μsForEachIterate1.02× · 0 B allocated12.9 μsQueryWrite1.49× · 0 B allocated18.9 μsRawArrayWrite1.01× · 0 B allocated12.8 μsForEachSystemWrite0.72× · 0 B allocated9.13 μsForEachWrite0.75× · 0 B allocated9.55 μsQueryIterate30.77× · 0 B allocated9.71 μsHandleAccess0.26× · 0 B allocated3.33 μsSingletonAccess0.08× · 0 B allocated1.01 μsTryGetEntity0.28× · 0 B allocated3.60 μsTrackedHandleWrite0.66× · 0 B allocated8.37 μsCountAndAny3.3× · 0 B allocated41.1 μs0.00 ns200 μs400 μs600 μs800 μs1.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
CreateAddDestroy1.03 ms82×1.52 MB
Churn334 μs26×0 B
ChurnBatch157 μs12×0 B
RemoveMany51.0 μs4.0×0 B
ToggleComponent158 μs13×0 B
QueryIterate30.5 μs2.41×0 B
ForEachIterate12.9 μs1.02×0 B
QueryWrite18.9 μs1.49×0 B
RawArrayWrite12.8 μs1.01×0 B
ForEachSystemWrite9.13 μs0.72×0 B
ForEachWrite9.55 μs0.75×0 B
QueryIterate39.71 μs0.77×0 B
HandleAccess3.33 μs0.26×0 B
SingletonAccess1.01 μs0.08×0 B
TryGetEntity3.60 μs0.28×0 B
TrackedHandleWrite8.37 μs0.66×0 B
CountAndAny41.1 μs3.3×0 B

CallSiteBenchmark measures a query call itself: a filter built at the call, a filter built once, no filter, and a filter past the per-call memo (the query cache's dictionary). RunnerBenchmark runs one pass outside systems three ways: a static [ForEach] method's entry point, the struct job it replaces written by hand, and a Query loop. OrderingBenchmark shows that [UpdateAfter<T>] costs nothing per update: the order is resolved when systems are added.

CallSiteBenchmark

FilterAtCall0 B allocated74.8 nsFilterOnce0.29× · 0 B allocated21.6 nsNoFilter0.57× · 0 B allocated42.9 nsPastTheMemo1.18× · 0 B allocated88.0 ns0.00 ns20.0 ns40.0 ns60.0 ns80.0 nsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
FilterAtCall74.8 ns1.00×0 B
FilterOnce21.6 ns0.29×0 B
NoFilter42.9 ns0.57×0 B
PastTheMemo88.0 ns1.18×0 B

RunnerBenchmark

Runner0 B allocated33.7 μsHandWrittenJob1.69× · 0 B allocated56.7 μsQuery4.3× · 0 B allocated145 μs0.00 ns20.0 μs40.0 μs60.0 μs80.0 μs100 μs120 μs140 μs160 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Runner33.7 μs1.00×0 B
HandWrittenJob56.7 μs1.69×0 B
Query145 μs4.3×0 B

OrderingBenchmark

Registered1.01× · 0 B allocated20.9 μsOrdered1.01× · 0 B allocated20.8 μs0.00 ns5.00 μs10.0 μs15.0 μs20.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Registered20.9 μs1.01×0 B
Ordered20.8 μs1.01×0 B

Presence bits and filters

SparseBenchmark keeps 10 burning units among 100,000 in one table (only their presence bits differ): a pass over the few, a query over them, a count of them and a pass over the rest. CountBenchmark counts rows that must be tested one by one (two columns with disabled rows), which is vectorized: 8 bit words per step with AVX-512. MaybeBenchmark compares one method taking Maybe<Shield> with two methods split by [With<Shield>] / [Without<Shield>].

SparseBenchmark

PassOverTheFew0 B allocated386 nsQueryTheFew0 B allocated365 nsCountTheFew0 B allocated13.6 nsPassOverTheRest0 B allocated52.3 μs0.00 ns10.0 μs20.0 μs30.0 μs40.0 μs50.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
PassOverTheFew386 ns—0 B
QueryTheFew365 ns—0 B
CountTheFew13.6 ns—0 B
PassOverTheRest52.3 μs—0 B
CaseMeanvs baselineAllocated
Count1.20 μs—0 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

MaybeBenchmark

OneMethod1.01× · 0 B allocated130 μsTwoMethods0.32× · 0 B allocated41.8 μs0.00 ns20.0 μs40.0 μs60.0 μs80.0 μs100 μs120 μs140 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
OneMethod130 μs1.01×0 B
TwoMethods41.8 μs0.32×0 B

Structural changes in bulk

BulkBenchmark stuns 100,000 fighters and lifts the stun, and disables a status for a zone and enables it, each in bulk (SetAll / RemoveAll, DisableAll / EnableAll) and entity by entity. PrefabBenchmark spawns 1,000 entities from a prefab one by one and as a wave. CleanupBenchmark churns 1,000 of 10,000 sessions per operation with a cleanup component against a plain component released by hand.

BulkBenchmark

StunAndLift0 B allocated87.9 μsStunAndLiftEach19× · 0 B allocated1.68 msDisableAndEnable0.26× · 0 B allocated22.9 μsDisableAndEnableEach26× · 0 B allocated2.27 ms0.00 ns500 μs1.00 ms1.50 ms2.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
StunAndLift87.9 μs1.00×0 B
StunAndLiftEach1.68 ms19×0 B
DisableAndEnable22.9 μs0.26×0 B
DisableAndEnableEach2.27 ms26×0 B

PrefabBenchmark

InstantiateEach0 B allocated49.7 μsInstantiateBatch0.31× · 0 B allocated15.3 μs0.00 ns10.0 μs20.0 μs30.0 μs40.0 μs50.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
InstantiateEach49.7 μs1.00×0 B
InstantiateBatch15.3 μs0.31×0 B

CleanupBenchmark

Cleanup0 B allocated102 μsPlain0.43× · 0 B allocated43.9 μs0.00 ns20.0 μs40.0 μs60.0 μs80.0 μs100 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Cleanup102 μs1.00×0 B
Plain43.9 μs0.43×0 B

Change tracking

ChangeTrackingBenchmark replicates health: 10 (a quiet tick) or 1,000 of 100,000 entities are written per tick, then one system copies health into a replica with [Changed<Health>] (Changed=True) or by visiting every row. QueryTick does the same with an ad-hoc Query. DynamicBufferBenchmark replicates 1,000 changed bags of 100,000, held as a DynamicBuffer<int> or as a List<int> in a tracked component.

ChangeTrackingBenchmark (Written=10)

Tick (Changed=False)0 B allocated38.6 μsQueryTick (Changed=False)0 B allocated476 μsTick (Changed=True)0 B allocated525 nsQueryTick (Changed=True)0 B allocated720 ns0.00 ns100 μs200 μs300 μs400 μs500 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseChangedMeanvs baselineAllocated
TickFalse38.6 μs—0 B
QueryTickFalse476 μs—0 B
TickTrue525 ns—0 B
QueryTickTrue720 ns—0 B

DynamicBufferBenchmark

Tick (List=False)0 B allocated56.5 μsTick (List=True)0 B allocated61.8 μs0.00 ns10.0 μs20.0 μs30.0 μs40.0 μs50.0 μs60.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseListMeanvs baselineAllocated
TickFalse56.5 μs—0 B
TickTrue61.8 μs—0 B

The "every row" cases vary from run to run on the reference VM (they depend on how 100,000 rows land in physical memory); the [Changed] cases are stable.

Indexes, relations, groups and hierarchies

IndexBenchmark uses a relation as an inventory: 100,000 items point at one of 1,000 owners; 100 trades, then 100 inventories counted. OrderedIndexBenchmark keeps a leaderboard of 100,000 scores (1,000 change, then the top 10 and one bracket read) against a scan. GroupBenchmark sums the players of 4 of 16 zones as a group (a table per zone), a value index and a scan. RelationBenchmark rewires 100 of 10,000 friend lists and walks 100 follower sets. HierarchyBenchmark destroys 1,000 squad leaders with their members (ChildOf, cascade) against links that are only removed.

CaseMeanvs baselineAllocated
TradeAndCount5.28 μs—0 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

OrderedIndexBenchmark

Ordered0 B allocated75.8 μsScan4.1× · 0 B allocated307 μs0.00 ns50.0 μs100 μs150 μs200 μs250 μs300 μs350 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Ordered75.8 μs1.00×0 B
Scan307 μs4.1×0 B

GroupBenchmark

Group1.01× · 0 B allocated47.4 μsIndex2.93× · 0 B allocated138 μsScan16× · 0 B allocated742 μs0.00 ns100 μs200 μs300 μs400 μs500 μs600 μs700 μs800 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Group47.4 μs1.01×0 B
Index138 μs2.93×0 B
Scan742 μs16×0 B
CaseMeanvs baselineAllocated
FollowAndCount22.7 μs—0 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

HierarchyBenchmark

Cascade0 B allocated590 μsRemoveLinks0.88× · 0 B allocated516 μs0.00 ns100 μs200 μs300 μs400 μs500 μs600 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Cascade590 μs1.00×0 B
RemoveLinks516 μs0.88×0 B

Threads

ParallelSystemsBenchmark runs four [ForEach] systems with disjoint access over 100,000 entities, with WorldOptions.ParallelSystems off and on: on, they form one stage and run at once. ParallelForEachBenchmark runs one heavy method (steering towards the nearest of 16 waypoints) plain and with Parallel = true, and the same work as an ad-hoc job with entity handles (ForEachEntity / ForEachEntityParallel).

ParallelSystemsBenchmark

Tick (Parallel=False)0 B allocated420 μsTick (Parallel=True)0 B allocated295 μs0.00 ns100 μs200 μs300 μs400 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseParallelMeanvs baselineAllocated
TickFalse420 μs—0 B
TickTrue295 μs—0 B

ParallelForEachBenchmark

Tick (Parallel=False)0 B allocated1.68 msEntityJob (Parallel=False)0 B allocated1.92 msTick (Parallel=True)0 B allocated884 μsEntityJob (Parallel=True)0 B allocated896 μs0.00 ns500 μs1.00 ms1.50 ms2.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseParallelMeanvs baselineAllocated
TickFalse1.68 ms—0 B
EntityJobFalse1.92 ms—0 B
TickTrue884 μs—0 B
EntityJobTrue896 μs—0 B

The reference machine has 4 cores and the parallel rows carry a large error in this run: read them as "faster on several cores", not as a precise speed-up.

Snapshots, saves, migration and unloading

SnapshotBenchmark captures a world of 100,000 entities (two tables, a third of the ids recycled, a singleton) into a new snapshot, restores one in place, saves it as bytes into a reused buffer and loads it back. Capture allocates the snapshot it returns; capture into an existing snapshot to reuse it. MigrationBenchmark moves 10 players with 99 items each to another world and back, through bytes (SaveEntities / LoadEntities) and in memory (MoveEntities); SaveAndLoadOne is the fixed cost of a save. UnloadBenchmark removes a plugin's types from a world of 10,000 or 100,000 players (RemoveTypes), the step before reloading game logic.

SnapshotBenchmark

Capture2.67 MB allocated931 μsRestore0 B allocated428 μsSave0 B allocated262 μsLoad0 B allocated1.00 ms0.00 ns200 μs400 μs600 μs800 μs1.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
Capture931 μs—2.67 MB
Restore428 μs—0 B
Save262 μs—0 B
Load1.00 ms—0 B

MigrationBenchmark

SaveAndLoad1.00× · 0 B allocated222 μsMove0.74× · 0 B allocated165 μsSaveAndLoadOne0.01× · 0 B allocated2.22 μsSaveRecord0.00× · 0 B allocated104 nsLoadRecord0.00× · 0 B allocated722 ns0.00 ns50.0 μs100 μs150 μs200 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CaseMeanvs baselineAllocated
SaveAndLoad222 μs1.00×0 B
Move165 μs0.74×0 B
SaveAndLoadOne2.22 μs0.01×0 B
SaveRecord104 ns0.00×0 B
LoadRecord722 ns0.00×0 B

UnloadBenchmark

RemoveTypes (Players=10000)2.95 KB allocated247 μsRemoveTypes (Players=100000)2.95 KB allocated2.38 ms0.00 ns500 μs1.00 ms1.50 ms2.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
CasePlayersMeanvs baselineAllocated
RemoveTypes10000247 μs—2.95 KB
RemoveTypes1000002.38 ms—2.95 KB

Introspection

IntrospectionBenchmark describes the battle server's world for a dashboard (world.Describe(): every table with its columns, rows and bytes) and one entity for a debugger (entity.Describe(), values boxed). Both allocate the description they return: they are tools, not tick paths.

CaseMeanvs baselineAllocated
Tables10.6 μs—25.0 KB
Entity244 ns—832 B
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

How to reproduce

Numbers come from BenchmarkDotNet only, never from a stopwatch:

dotnet run -c Release --project benchmarks/EasyEcs.Benchmark -- --filter '*'             # every class on this page
dotnet run -c Release --project benchmarks/EasyEcs.Benchmark -- --filter '*World*'       # the headline ticks
dotnet run -c Release --project benchmarks/EasyEcs.Comparison -- --filter '*'            # other libraries
dotnet run -c Release --project benchmarks/EasyEcs.Comparison -- --check                 # correctness of the ports only

Both projects use the job in benchmarks/EasyEcs.Benchmark/BenchmarkConfig.cs: 2 launches, 6 warmups, 8 iterations of 250 ms, and call counting from the start (DOTNET_TC_CallCountingDelayMs=0) so the warmups reach optimized code. Two processes are measured instead of many iterations of one, because run-to-run differences (code layout, tiering) are larger than the noise within a run. The machine of the numbers on this site:

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

AllocationTests guard the zero-allocation contract on every test run (dotnet test): the steady-state tick, queries, structural changes, indexes, relations, cascades and parallel passes must allocate 0 bytes after warm-up.

Edit on GitHub

Last updated on

How is this guide?

On this page