mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
feat: use alien-signals
This commit is contained in:
parent
d7a1f62c3c
commit
861ee5acd7
76 changed files with 3112 additions and 1862 deletions
38
tests/benchmarks/propagate.bench.luau
Normal file
38
tests/benchmarks/propagate.bench.luau
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Charm = require(ReplicatedStorage.DevPackages.Charm)
|
||||
local signals = require(ReplicatedStorage.DevPackages.Charm.signals)
|
||||
|
||||
local function propagate(
|
||||
signal: <T>(T) -> (T?) -> T,
|
||||
computed: <T>(() -> T) -> () -> T,
|
||||
effect: (() -> ()) -> (),
|
||||
w: number,
|
||||
h: number
|
||||
)
|
||||
local src = signal(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
|
||||
|
||||
return {
|
||||
Functions = {
|
||||
charm = function()
|
||||
propagate(Charm.atom, Charm.computed, Charm.effect, 10, 10)
|
||||
end,
|
||||
alien_signals = function()
|
||||
propagate(signals.signal, signals.computed, signals.effect, 10, 10)
|
||||
end,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue