From 1651de4f297579d0943c59b27db9bc5ec9cd6585 Mon Sep 17 00:00:00 2001 From: alice <166900055+alicesaidhi@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:18:38 -0700 Subject: [PATCH] add relationship benchmark --- benches/general.luau | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/benches/general.luau b/benches/general.luau index 30343e2..3f2247b 100644 --- a/benches/general.luau +++ b/benches/general.luau @@ -61,6 +61,42 @@ do TITLE "set" end) end +-- we have a separate benchmark for relationships. +-- this is due to that relationships have a very high id compared to normal +-- components, which cause them to get added into the hashmap portion. +do TITLE "set relationship" + + local world = jecs.World.new() + local A = world:entity() + + local entities = table.create(N) + + for i = 1, N do + entities[i] = world:entity() + world:set(entities[i], A, 1) + end + + local pair = jecs.pair(A, world:entity()) + + BENCH("add", function() + for i = 1, START(N) do + world:set(entities[i], pair, 1) + end + end) + + BENCH("set", function() + for i = 1, START(N) do + world:set(entities[i], pair, 2) + end + end) + + BENCH("remove", function() + for i = 1, START(N) do + world:remove(entities[i], pair) + end + end) +end + do TITLE "get" local world = jecs.World.new()