mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
refactor: improve structure and alien-signals integration
This commit is contained in:
parent
a9c60c701f
commit
95476e93ec
107 changed files with 3660 additions and 815 deletions
|
|
@ -1,10 +1,10 @@
|
|||
local Charm = require("@packages/charm/src")
|
||||
local Charm = require("../packages/charm/src")
|
||||
local bench = require("./bench")
|
||||
|
||||
local atom = Charm.atom
|
||||
local computed = Charm.computed
|
||||
local mapped = Charm.mapped
|
||||
local setCurrentSub = Charm.signals.setCurrentSub
|
||||
local setCurrentSub = Charm.core.setCurrentSub
|
||||
|
||||
type Entry = { number }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local CharmSync = require(ReplicatedStorage.Packages.CharmSync)
|
||||
local CharmSync = require("../packages/charm-sync/src")
|
||||
|
||||
local patch = CharmSync.patch
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,27 @@
|
|||
local Charm = require("@packages/charm/src")
|
||||
local Charm = require("../packages/charm/src")
|
||||
local bench = require("./bench")
|
||||
|
||||
local signals = Charm.signals
|
||||
local atom = Charm.atom
|
||||
local computed = Charm.computed
|
||||
local effect = Charm.effect
|
||||
|
||||
for _, w in { 10, 100 } do
|
||||
for _, h in { 10, 100 } do
|
||||
bench.run(`charm {w}*{h}`, function()
|
||||
local src = Charm.atom(1)
|
||||
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 = Charm.computed(function()
|
||||
last = computed(function()
|
||||
return prev() + 1
|
||||
end)
|
||||
end
|
||||
Charm.effect(function()
|
||||
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