Add cleanup() benchmarks

This commit is contained in:
Aaron Smith 2023-08-14 17:06:15 +01:00
parent 99b5aea270
commit 6acd054294
2 changed files with 40 additions and 3 deletions

View file

@ -247,4 +247,37 @@ BENCH("values() all remove", function()
state(data)
end)
BENCH("register cleanup", function()
local cleanup = vide.cleanup
local function foo(i)
cleanup(function() -- todo: why is this not causing allocations?
return i
end)
end
for i = 1, START(N) do
foo(i)
end
end)
BENCH("cleanup step", function()
local cleanup = vide.cleanup
local ref = table.create(N)
for i = 1, N do
ref[i] = function()
cleanup(function() end)
return i
end
ref[i]()
end
START(N)
vide.step(0)
end)
return nil