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 15:28: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 30.8 ns
Query.EntityAt, 5 arch 4.3 ns registered filter
World.Query 47.4 ns
World.Query 34.4 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 17.0 ns memory already allocated
World.NewEntity w/ 1 Comp 34.4 ns memory already allocated
World.NewEntity w/ 5 Comps 45.2 ns memory already allocated
World.RemoveEntity 14.7 ns
World.RemoveEntity w/ 1 Comp 26.6 ns
World.RemoveEntity w/ 5 Comps 54.9 ns
World.NewEntityWith w/ 1 Comp 72.8 ns ⚠️ deprecated, memory already allocated
World.NewEntityWith w/ 5 Comps 227.1 ns ⚠️ deprecated, memory already allocated
MapX.NewEntityWith w/ 1 Comp 28.5 ns memory already allocated
MapX.NewEntityWith w/ 5 Comps 70.3 ns memory already allocated

Entities, batched

Operation Time Remark
Builder.NewBatch 10.1 ns 1000, memory already allocated
Builder.NewBatch w/ 1 Comp 10.5 ns 1000, memory already allocated
Builder.NewBatch w/ 5 Comps 9.9 ns 1000, memory already allocated
Batch.RemoveEntities 6.8 ns 1000
Batch.RemoveEntities w/ 1 Comp 7.7 ns 1000
Batch.RemoveEntities w/ 5 Comps 7.6 ns 1000

Components

Operation Time Remark
World.Add 1 Comp 74.5 ns memory already allocated
World.Add 5 Comps 92.3 ns memory already allocated
World.Remove 1 Comp 86.2 ns
World.Remove 5 Comps 128.1 ns
World.Exchange 1 Comp 83.7 ns memory already allocated
World.Assign 1 Comp 111.3 ns ⚠️ deprecated, memory already allocated
World.Assign 5 Comps 276.4 ns ⚠️ deprecated, memory already allocated
MapX.Assign 1 Comps 70.3 ns memory already allocated
MapX.Assign 5 Comps 123.1 ns memory already allocated

Components, batched

Operation Time Remark
Batch.Add 1 Comp 8.5 ns 1000, memory already allocated
Batch.Add 5 Comps 9.0 ns 1000, memory already allocated
Batch.Remove 1 Comp 9.9 ns 1000
Batch.Remove 5 Comps 14.7 ns 1000
Batch.Exchange 1 Comp 9.6 ns 1000, memory already allocated