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: Mon, 20 Jan 2025 12:44:42 UTC
Version: Arche v0.15.2
CPU: AMD EPYC 7763 64-Core Processor

Query

Operation Time Remark
Query.Next 1.0 ns
Query.Next + 1x Query.Get 1.6 ns
Query.Next + 2x Query.Get 1.9 ns
Query.Next + 5x Query.Get 4.4 ns
Query.Next + Query.Entity 1.8 ns
Query.Next + Query.Relation 2.2 ns
Query.EntityAt, 1 arch 12.2 ns
Query.EntityAt, 1 arch 3.2 ns registered filter
Query.EntityAt, 5 arch 30.6 ns
Query.EntityAt, 5 arch 4.9 ns registered filter
World.Query 30.5 ns
World.Query 35.0 ns registered filter

World access

Operation Time Remark
World.Get 2.0 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.7 ns memory already allocated
World.NewEntity w/ 1 Comp 24.2 ns memory already allocated
World.NewEntity w/ 5 Comps 47.2 ns memory already allocated
World.RemoveEntity 15.7 ns
World.RemoveEntity w/ 1 Comp 26.8 ns
World.RemoveEntity w/ 5 Comps 60.2 ns
Map1.NewWith 1 Comp 29.7 ns memory already allocated
Map5.NewWith 5 Comps 73.3 ns memory already allocated

Entities, batched

Operation Time Remark
Batch.New 10.1 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.3 ns 1000
Batch.RemoveEntities w/ 1 Comp 7.7 ns 1000
Batch.RemoveEntities w/ 5 Comps 8.8 ns 1000

Components

Operation Time Remark
World.Add 1 Comp 42.3 ns memory already allocated
World.Add 5 Comps 70.7 ns memory already allocated
World.Add 1 to 5 Comps 111.2 ns memory already allocated
World.Remove 1 Comp 51.2 ns memory already allocated
World.Remove 5 Comps 110.8 ns memory already allocated
World.Remove 1 of 5 Comps 106.3 ns memory already allocated
World.Exchange 1 Comp 57.8 ns memory already allocated
World.Exchange 1 of 5 Comps 114.7 ns memory already allocated
Map1.Assign 1 Comps 46.1 ns memory already allocated
Map5.Assign 5 Comps 98.0 ns memory already allocated

Components, batched

Operation Time Remark
Batch.Add 1 Comp 4.4 ns 1000, memory already allocated
Batch.Add 5 Comps 4.5 ns 1000, memory already allocated
Batch.Add 1 to 5 Comps 7.9 ns 1000, memory already allocated
Batch.Remove 1 Comp 4.5 ns 1000, memory already allocated
Batch.Remove 5 Comps 5.7 ns 1000, memory already allocated
Batch.Remove 1 of 5 Comps 7.0 ns 1000, memory already allocated
Batch.Exchange 1 Comp 4.6 ns 1000, memory already allocated
Batch.Exchange 1 of 5 Comps 7.0 ns 1000, memory already allocated

Other

Operation Time Remark
ecs.NewWorld 6.7 μs
World.Reset 79.7 ns empty world
ecs.ComponentID 22.2 ns component already registered