Optimize cleanup

This commit is contained in:
aaron 2023-08-14 22:51:31 +01:00
parent 6acd054294
commit 154cf77df6
2 changed files with 47 additions and 18 deletions

View file

@ -250,6 +250,23 @@ end)
BENCH("register cleanup", function()
local cleanup = vide.cleanup
local callers = {}
for i = 1, N do
callers[i] = function(fn, v)
fn(v)
return i
end
end
for i = 1, START(N) do
callers[i](cleanup, function() end)
end
end)
BENCH("repeat cleanup", function()
local cleanup = vide.cleanup
local function foo(i)
cleanup(function() -- todo: why is this not causing allocations?
return i
@ -261,6 +278,8 @@ BENCH("register cleanup", function()
end
end)
-- todo: this is sometimes never terminates
BENCH("cleanup step", function()
local cleanup = vide.cleanup