mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 11:44:08 +00:00
test: add patch benchmark
This commit is contained in:
parent
d703990e5b
commit
884e6c0e8c
2 changed files with 70 additions and 24 deletions
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue