mirror of
https://github.com/littensy/charm.git
synced 2026-10-22 12:34:09 +00:00
perf: optimize mapped, add benches
This commit is contained in:
parent
d56672384a
commit
ada1b80b87
12 changed files with 385 additions and 161 deletions
27
benchmarks/propagate.luau
Normal file
27
benchmarks/propagate.luau
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue