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: Tue, 10 Sep 2024 12:59:48 UTC

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.3 ns
Query.Next + Query.Relation 2.2 ns
Query.EntityAt, 1 arch 12.0 ns
Query.EntityAt, 1 arch 2.8 ns registered filter
Query.EntityAt, 5 arch 31.3 ns
Query.EntityAt, 5 arch 4.3 ns registered filter
World.Query 44.8 ns
World.Query 34.6 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.3 ns random, 1000 entities
World.HasUnchecked 0.7 ns random, 1000 entities
World.Alive 0.6 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.2 ns
World.NewEntity 16.6 ns memory already allocated
World.NewEntity w/ 1 Comp 33.2 ns memory already allocated
World.NewEntity w/ 5 Comps 47.1 ns memory already allocated
World.RemoveEntity 15.1 ns
World.RemoveEntity w/ 1 Comp 26.3 ns
World.RemoveEntity w/ 5 Comps 55.2 ns

Entities, batched

Operation Time Remark
Builder.NewBatch 10.4 ns 1000, memory already allocated
Builder.NewBatch w/ 1 Comp 10.5 ns 1000, memory already allocated
Builder.NewBatch w/ 5 Comps 10.1 ns 1000, memory already allocated
Batch.RemoveEntities 7.3 ns 1000
Batch.RemoveEntities w/ 1 Comp 7.1 ns 1000
Batch.RemoveEntities w/ 5 Comps 7.5 ns 1000

Components

Operation Time Remark
World.Add 1 Comp 76.4 ns memory already allocated
World.Add 5 Comps 90.4 ns memory already allocated
World.Remove 1 Comp 82.2 ns
World.Remove 5 Comps 127.2 ns
World.Exchange 1 Comp 79.0 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 9.5 ns 1000
Batch.Remove 5 Comps 15.0 ns 1000
Batch.Exchange 1 Comp 10.3 ns 1000, memory already allocated