test: add patch benchmark

This commit is contained in:
Richard 2025-01-25 15:05:55 -08:00
parent d703990e5b
commit 884e6c0e8c
2 changed files with 70 additions and 24 deletions

View file

@ -4,29 +4,27 @@ local Charm = require(ReplicatedStorage.DevPackages.Charm)
local computed = Charm.computed
local atom = Charm.atom
local function parameterGenerator()
return atom(0)
end
local benchmarks = {
atom = function(_, state: any)
for _ = 1, 500 do
state(math.random(1, 2))
end
end,
computed = function(_, state: any)
computed(function()
return 2 * state()
end)
for _ = 1, 500 do
state(math.random(1, 2))
end
end,
}
return {
ParameterGenerator = parameterGenerator,
Functions = benchmarks,
ParameterGenerator = function() end,
Functions = {
atom = function()
local state = atom(0)
for _ = 1, 500 do
state(math.random(1, 2))
end
end,
computed = function()
local state = atom(0)
local _double = computed(function()
return 2 * state()
end)
for _ = 1, 500 do
state(math.random(1, 2))
end
end,
},
}