mirror of
https://github.com/littensy/charm.git
synced 2026-10-23 05:46:27 +00:00
46 lines
962 B
Lua
46 lines
962 B
Lua
-- This file is for use by Benchmarker
|
|
-- https://boatbomber.itch.io/benchmarker
|
|
|
|
local Package = game:GetService("ReplicatedStorage").Packages.charm
|
|
|
|
local atom = require(Package.atom)
|
|
local derive = require(Package.derive)
|
|
|
|
local function parameterGenerator()
|
|
return atom({ count = 0 })
|
|
end
|
|
|
|
local benchmarks = {
|
|
atom = function(_, source: any)
|
|
for _ = 1, 500 do
|
|
source({ count = math.random(1, 2) })
|
|
end
|
|
end,
|
|
|
|
derived = function(_, source: any)
|
|
derive(function()
|
|
return { count = 2 * source().count }
|
|
end)
|
|
for _ = 1, 500 do
|
|
source({ count = math.random(1, 2) })
|
|
end
|
|
end,
|
|
|
|
derived_memo = function(_, source: any)
|
|
derive(function()
|
|
return { count = 2 * source().count }
|
|
end, {
|
|
equals = function(previous, current)
|
|
return previous.count == current.count
|
|
end,
|
|
})
|
|
for _ = 1, 500 do
|
|
source({ count = math.random(1, 2) })
|
|
end
|
|
end,
|
|
}
|
|
|
|
return {
|
|
ParameterGenerator = parameterGenerator,
|
|
Functions = benchmarks,
|
|
}
|