From f704acce71534901bf909f02172c5998cdf73ea1 Mon Sep 17 00:00:00 2001 From: littensy <56808540+littensy@users.noreply.github.com> Date: Tue, 6 May 2025 16:27:50 -0700 Subject: [PATCH] chore: delete redundant benchmarks --- benchmarks/mapped.bench.luau | 99 --------------------------------- benchmarks/propagate.bench.luau | 63 --------------------- 2 files changed, 162 deletions(-) delete mode 100644 benchmarks/mapped.bench.luau delete mode 100644 benchmarks/propagate.bench.luau diff --git a/benchmarks/mapped.bench.luau b/benchmarks/mapped.bench.luau deleted file mode 100644 index 89fdfad..0000000 --- a/benchmarks/mapped.bench.luau +++ /dev/null @@ -1,99 +0,0 @@ ---!optimize 2 - -local ReplicatedStorage = game:GetService("ReplicatedStorage") - -local Charm = require(ReplicatedStorage.Packages.Charm) - -local atom = Charm.atom -local computed = Charm.computed -local mapped = Charm.mapped -local pauseTracking = Charm.signals.pauseTracking -local resumeTracking = Charm.signals.resumeTracking - -type Entry = { number } - -local count = 512 -local initialState: { Entry } = table.create(count) - -for i = 1, count do - initialState[i] = table.create(32, i) -end - -local function mapper(value: Entry): Entry - return table.clone(value) -end - -local function simpleMapped(source: () -> { Entry }): () -> { Entry } - return computed(function() - local state = source() - local nextState = {} - - for index, value in state do - pauseTracking() - local success, valueOut = pcall(mapper, value) - resumeTracking() - - if success then - nextState[index] = valueOut - end - end - - return state - end) -end - -local function updatePercentage(percent: number): ({ Entry }) -> { Entry } - return function(state) - local nextState = table.clone(state) - for index, value in state do - if math.random() < percent then - nextState[index] = table.clone(value) - end - end - return nextState - end -end - -local function test( - percent: number, - profiler: any, - mapped: (src: () -> { Entry }, ...(Entry) -> Entry) -> () -> { Entry } -) - local src = atom(initialState) - local out = mapped(src, mapper) - - profiler.Begin("init") - out() - profiler.End() - - profiler.Begin("setup") - src(updatePercentage(percent)) - profiler.End() - - profiler.Begin("update") - out() - profiler.End() -end - -return { - Functions = { - ["mapped 10%"] = function(profiler) - test(0.1, profiler, mapped) - end, - ["mapped 50%"] = function(profiler) - test(0.5, profiler, mapped) - end, - ["mapped 100%"] = function(profiler) - test(1, profiler, mapped) - end, - ["control 10%"] = function(profiler) - test(0.1, profiler, simpleMapped) - end, - ["control 50%"] = function(profiler) - test(0.5, profiler, simpleMapped) - end, - ["control 100%"] = function(profiler) - test(1, profiler, simpleMapped) - end, - }, -} diff --git a/benchmarks/propagate.bench.luau b/benchmarks/propagate.bench.luau deleted file mode 100644 index e2b0260..0000000 --- a/benchmarks/propagate.bench.luau +++ /dev/null @@ -1,63 +0,0 @@ -local ReplicatedStorage = game:GetService("ReplicatedStorage") - -local Charm = require(ReplicatedStorage.Packages.Charm) - -local atom = Charm.atom -local computed = Charm.computed -local effect = Charm.effect -local listen = Charm.listen - -local function propagate(w: number, h: number) - local src = atom(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 - -local function propagateListen(w: number, h: number) - local src = atom(1) - for _ = 1, w do - local last = src - for _ = 1, h do - local prev = last - last = computed(function() - return prev() + 1 - end) - end - listen(last, function() end) - end - src(src() + 1) -end - -return { - Functions = { - ["effect 1*100"] = function() - propagate(1, 100) - end, - ["effect 100*1"] = function() - propagate(100, 1) - end, - ["effect 10*10"] = function() - propagate(10, 10) - end, - ["listen 1*100"] = function() - propagateListen(1, 100) - end, - ["listen 100*1"] = function() - propagateListen(100, 1) - end, - ["listen 10*10"] = function() - propagateListen(10, 10) - end, - }, -}