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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue