mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Add cleanup() benchmarks
This commit is contained in:
parent
99b5aea270
commit
6acd054294
2 changed files with 40 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue