mirror of
https://github.com/littensy/charm.git
synced 2026-10-22 21:01:38 +00:00
refactor: improve logic
This commit is contained in:
parent
210e948225
commit
72f936591e
48 changed files with 434 additions and 349 deletions
42
benches/propagate.luau
Normal file
42
benches/propagate.luau
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
local Charm = require("@pkgs/charm/src/lib")
|
||||
local bench = require("./bench")
|
||||
|
||||
local signals = Charm.signals
|
||||
|
||||
for _, w in { 10, 100 } do
|
||||
for _, h in { 10, 100 } do
|
||||
bench.run(`charm {w}*{h}`, function()
|
||||
local src = Charm.atom(1)
|
||||
for _ = 1, w do
|
||||
local last = src
|
||||
for _ = 1, h do
|
||||
local prev = last
|
||||
last = Charm.computed(function()
|
||||
return prev() + 1
|
||||
end)
|
||||
end
|
||||
Charm.effect(function()
|
||||
last()
|
||||
end)
|
||||
end
|
||||
src(src() + 1)
|
||||
end)
|
||||
|
||||
bench.run(`alien-signals {w}*{h}`, function()
|
||||
local src, setSrc = signals.signal(1)
|
||||
for _ = 1, w do
|
||||
local last = src
|
||||
for _ = 1, h do
|
||||
local prev = last
|
||||
last = signals.computed(function()
|
||||
return prev() + 1
|
||||
end)
|
||||
end
|
||||
signals.effect(function()
|
||||
last()
|
||||
end)
|
||||
end
|
||||
setSrc(src() + 1)
|
||||
end)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue