perf: optimize mapped, add benches

This commit is contained in:
littensy 2025-05-06 16:27:06 -07:00
parent d56672384a
commit ada1b80b87
12 changed files with 385 additions and 161 deletions

27
benchmarks/propagate.luau Normal file
View file

@ -0,0 +1,27 @@
local Charm = require("@pkgs/charm/src/lib")
local bench = require("./bench")
local atom = Charm.atom
local computed = Charm.computed
local effect = Charm.effect
for _, w in { 1, 10, 100 } do
for _, h in { 1, 10, 100 } do
bench.run(`propagate {w}*{h}`, function()
local src = atom(1)
for _ = 1, w do
local last = src
for _ = 1, h do
local prev = last
last = computed(function()
return prev() + 1
end)
end
effect(function()
last()
end)
end
src(src() + 1)
end)
end
end