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

View file

@ -1,6 +1,6 @@
--------------------------------------------------------------------------------
-- testkit.luau
-- v0.7.0
-- v0.7.1
--------------------------------------------------------------------------------
local color = {
@ -39,23 +39,27 @@ local color = {
local function convert_units(unit: string, value: number): (number, string)
local prefix_colors = {
[4] = color.red,
[3] = color.red,
[2] = color.yellow,
[1] = color.yellow,
[0] = color.green,
[-1] = color.red,
[-2] = color.yellow,
[-3] = color.green
[-3] = color.green,
[-4] = color.red
}
local prefixes = {
[4] = "T",
[3] ="G",
[2] ="M",
[1] = "k",
[0] = " ",
[-1] = "m",
[-2] = "u",
[-3] = "n"
[-3] = "n",
[-4] = "p"
}
local order = 0