Ark
Benchmarks

Benchmarks

This chapter gives an overview of the runtime cost of typical Ark 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 Ark.


Last run: Sun, 09 Mar 2025 00:48:48 UTC
Version: Ark v0.3.0
CPU: AMD EPYC 7763 64-Core Processor

Query

Operation Time Remark
Query.Next 1.8 ns
Query.Next + Query.Get 1 3.2 ns
Query.Next + Query.Get 2 3.2 ns
Query.Next + Query.Get 5 3.9 ns
Query.Next + Query.Entity 3.2 ns
Query.Next + Query.Relation 3.5 ns
Filter1.Query + Query1.Close 42.1 ns
Filter1.Query + Query1.Close 44.0 ns registered filter

World access

Operation Time Remark
Map.Get 3.4 ns random, 1000 entities
Map.GetUnchecked 3.2 ns random, 1000 entities
Map.Has 2.9 ns random, 1000 entities
Map.HasUnchecked 2.3 ns random, 1000 entities
World.Alive 1.8 ns random, 1000 entities
Map.GetRelation 4.2 ns random, 1000 entities
Map.GetRelation 3.9 ns random, 1000 entities

Entities

Operation Time Remark
Entity.IsZero 1.6 ns
World.NewEntity 14.6 ns memory already alloc.
Map1.NewEntityFn w/ 1 Comp 38.2 ns memory already alloc.
Map5.NewEntityFn w/ 5 Comps 57.9 ns memory already alloc.
Map1.NewEntity w/ 1 Comp 44.0 ns memory already alloc.
Map5.NewEntity w/ 5 Comps 97.2 ns memory already alloc.
World.RemoveEntity 14.3 ns
World.RemoveEntity w/ 1 Comp 19.3 ns
World.RemoveEntity w/ 5 Comps 42.1 ns

Entities, batched

Operation Time Remark
World.NewEntities 8.8 ns 1000, memory already alloc.
Map1.NewBatchFn w/ 1 Comp 8.7 ns 1000, memory already alloc.
Map5.NewBatchFn w/ 5 Comps 9.0 ns 1000, memory already alloc.
World.RemoveEntities 5.0 ns 1000
World.RemoveEntities w/ 1 Comp 5.4 ns 1000
World.RemoveEntities w/ 5 Comps 6.6 ns 1000

Components

Operation Time Remark
Map1.AddFn 1 Comp 43.6 ns memory already alloc.
Map5.AddFn 5 Comps 65.5 ns memory already alloc.
Map1.AddFn 1 to 5 Comps 108.9 ns memory already alloc.
Map1.Add 1 Comp 52.9 ns memory already alloc.
Map5.Add 5 Comps 108.9 ns memory already alloc.
Map1.Add 1 to 5 Comps 115.2 ns memory already alloc.
Map1.Remove 1 Comp 44.6 ns memory already alloc.
Map5.Remove 5 Comps 90.5 ns memory already alloc.
Map1.Remove 1 of 5 Comps 94.2 ns memory already alloc.
Exchange1.ExchangeFn 1 Comp 57.1 ns memory already alloc.
Exchange1.ExchangeFn 1 of 5 Comps 107.1 ns memory already alloc.
Exchange1.Exchange 1 Comp 67.6 ns memory already alloc.
Exchange1.Exchange 1 of 5 Comps 120.3 ns memory already alloc.

Components, batched

Operation Time Remark
Map1.AddBatchFn 1 Comp 3.8 ns 1000, memory already alloc.
Map5.AddBatchFn 5 Comps 3.9 ns 1000, memory already alloc.
Map1.AddBatchFn 1 to 5 Comps 7.0 ns 1000, memory already alloc.
Map1.RemoveBatch 1 Comp 3.9 ns 1000, memory already alloc.
Map5.RemoveBatch 5 Comps 5.1 ns 1000, memory already alloc.
Map1.RemoveBatch 1 of 5 Comps 6.5 ns 1000, memory already alloc.
Exchange1.ExchangeBatchFn 1 Comp 4.0 ns 1000, memory already alloc.
Exchange1.ExchangeBatchFn 1 of 5 Comps 6.5 ns 1000, memory already alloc.

Other

Operation Time Remark
ecs.NewWorld 13.4 μs
World.Reset 114.3 ns empty world
ecs.ComponentID 21.1 ns component already registered