Benchmarks

This chapter gives an overview of the runtime cost of typical Arche operations. All time information is per entity. 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, but may change depending on the hardware the CI runs on. For a benchmark comparison with other ECS implementations, see the benchmarks on the repo README.

Last run: Sun, 22 Dec 2024 19:52:38 UTC

Query

Operation Time Remark
Query.Next 1.0 ns
Query.Next + 1x Query.Get 1.7 ns
Query.Next + 2x Query.Get 1.9 ns
Query.Next + 5x Query.Get 4.4 ns
Query.Next + Query.Entity 1.3 ns
Query.Next + Query.Relation 2.2 ns
Query.EntityAt, 1 arch 12.1 ns
Query.EntityAt, 1 arch 3.1 ns registered filter
Query.EntityAt, 5 arch 31.9 ns
Query.EntityAt, 5 arch 4.3 ns registered filter
World.Query 46.4 ns
World.Query 34.5 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.3 ns random, 1000 entities
World.HasUnchecked 0.7 ns random, 1000 entities
World.Alive 0.4 ns random, 1000 entities
World.Relations.Get 3.5 ns random, 1000 entities
World.Relations.GetUnchecked 0.8 ns random, 1000 entities

Entities

Operation Time Remark
Entity.IsZero 0.3 ns
World.NewEntity 16.7 ns memory already allocated
World.NewEntity w/ 1 Comp 33.9 ns memory already allocated
World.NewEntity w/ 5 Comps 45.7 ns memory already allocated
World.RemoveEntity 15.5 ns
World.RemoveEntity w/ 1 Comp 26.4 ns
World.RemoveEntity w/ 5 Comps 54.0 ns
World.NewEntityWith w/ 1 Comp 70.7 ns ⚠️ deprecated, memory already allocated
World.NewEntityWith w/ 5 Comps 221.0 ns ⚠️ deprecated, memory already allocated
MapX.NewEntityWith w/ 1 Comp 28.3 ns memory already allocated
MapX.NewEntityWith w/ 5 Comps 71.1 ns memory already allocated

Entities, batched

Operation Time Remark
Builder.NewBatch 9.9 ns 1000, memory already allocated
Builder.NewBatch w/ 1 Comp 10.3 ns 1000, memory already allocated
Builder.NewBatch w/ 5 Comps 10.4 ns 1000, memory already allocated
Batch.RemoveEntities 6.7 ns 1000
Batch.RemoveEntities w/ 1 Comp 7.3 ns 1000
Batch.RemoveEntities w/ 5 Comps 7.7 ns 1000

Components

Operation Time Remark
World.Add 1 Comp 75.0 ns memory already allocated
World.Add 5 Comps 91.0 ns memory already allocated
World.Remove 1 Comp 85.5 ns
World.Remove 5 Comps 128.8 ns
World.Exchange 1 Comp 79.9 ns memory already allocated
World.Assign 1 Comp 110.2 ns ⚠️ deprecated, memory already allocated
World.Assign 5 Comps 271.5 ns ⚠️ deprecated, memory already allocated
MapX.Assign 1 Comps 70.0 ns memory already allocated
MapX.Assign 5 Comps 117.3 ns memory already allocated

Components, batched

Operation Time Remark
Batch.Add 1 Comp 8.6 ns 1000, memory already allocated
Batch.Add 5 Comps 8.8 ns 1000, memory already allocated
Batch.Remove 1 Comp 10.0 ns 1000
Batch.Remove 5 Comps 14.9 ns 1000
Batch.Exchange 1 Comp 9.6 ns 1000, memory already allocated