Benchmarks

Benchmarks

This chapter gives an overview of the runtime cost of typical Arche operations. All time information is per entity. All components used in the benchmarks have two int64 fields. Batch operations are performed in batches of 1000 entities.

Absolute numbers are not really meaningful, as they heavily depend on the hardware. However, all benchmarks run in the CI in the same job and hence on the same machine, and can be compared.

Benchmark code: benchmark/table in the GitHub repository.

Benchmarks are run automatically in the GitHub CI, and are updated on this page on every merge into the main branch. They always reflect the latest development state of Arche.

For a benchmark comparison with other ECS implementations, see the go-ecs-benchmarks repository.

Last run: Sun, 09 Mar 2025 09:31:41 UTC
Version: Arche v0.15.3
CPU: AMD EPYC 7763 64-Core Processor

Query

Operation Time Remark
Query.Next 1.0 ns
Query.Next + 1x Query.Get 1.7 ns
Query.Next + 2x Query.Get 2.0 ns
Query.Next + 5x Query.Get 4.4 ns
Query.Next + Query.Entity 1.7 ns
Query.Next + Query.Relation 2.3 ns
Query.EntityAt, 1 arch 12.0 ns
Query.EntityAt, 1 arch 3.1 ns registered filter
Query.EntityAt, 5 arch 30.9 ns
Query.EntityAt, 5 arch 4.9 ns registered filter
World.Query 30.5 ns
World.Query 35.4 ns registered filter

World access

Operation Time Remark
World.Get 2.1 ns random, 1000 entities
World.GetUnchecked 1.5 ns random, 1000 entities
World.Has 1.2 ns random, 1000 entities
World.HasUnchecked 0.7 ns random, 1000 entities
World.Alive 0.4 ns random, 1000 entities
World.Relations.Get 3.4 ns random, 1000 entities
World.Relations.GetUnchecked 0.8 ns random, 1000 entities

Entities

Operation Time Remark
Entity.IsZero 0.2 ns
World.NewEntity 16.6 ns memory already alloc.
World.NewEntity w/ 1 Comp 24.7 ns memory already alloc.
World.NewEntity w/ 5 Comps 47.0 ns memory already alloc.
World.RemoveEntity 15.6 ns
World.RemoveEntity w/ 1 Comp 28.1 ns
World.RemoveEntity w/ 5 Comps 59.0 ns
Map1.NewWith 1 Comp 31.3 ns memory already alloc.
Map5.NewWith 5 Comps 74.5 ns memory already alloc.

Entities, batched

Operation Time Remark
Batch.New 9.7 ns 1000, memory already allocated
Batch.New w/ 1 Comp 10.0 ns 1000, memory already allocated
Batch.New w/ 5 Comps 9.8 ns 1000, memory already allocated
Batch.RemoveEntities 7.1 ns 1000
Batch.RemoveEntities w/ 1 Comp 7.7 ns 1000
Batch.RemoveEntities w/ 5 Comps 8.5 ns 1000

Components

Operation Time Remark
World.Add 1 Comp 42.6 ns memory already alloc.
World.Add 5 Comps 70.0 ns memory already alloc.
World.Add 1 to 5 Comps 122.5 ns memory already alloc.
World.Remove 1 Comp 51.1 ns memory already alloc.
World.Remove 5 Comps 116.7 ns memory already alloc.
World.Remove 1 of 5 Comps 116.8 ns memory already alloc.
World.Exchange 1 Comp 58.8 ns memory already alloc.
World.Exchange 1 of 5 Comps 121.2 ns memory already alloc.
Map1.Assign 1 Comps 46.3 ns memory already alloc.
Map5.Assign 5 Comps 99.7 ns memory already alloc.

Components, batched

Operation Time Remark
Batch.Add 1 Comp 4.3 ns 1000, memory already allocated
Batch.Add 5 Comps 4.4 ns 1000, memory already allocated
Batch.Add 1 to 5 Comps 8.0 ns 1000, memory already allocated
Batch.Remove 1 Comp 4.4 ns 1000, memory already allocated
Batch.Remove 5 Comps 5.6 ns 1000, memory already allocated
Batch.Remove 1 of 5 Comps 7.2 ns 1000, memory already allocated
Batch.Exchange 1 Comp 4.5 ns 1000, memory already allocated
Batch.Exchange 1 of 5 Comps 7.2 ns 1000, memory already allocated

Other

Operation Time Remark
ecs.NewWorld 6.6 μs
World.Reset 79.8 ns empty world
ecs.ComponentID 22.1 ns component already registered