New test module 'tracegc'

New module easies the inclusion of GC tracing in individual test files.
This commit is contained in:
Roberto Ierusalimschy
2021-03-01 13:54:29 -03:00
parent f9d857a81b
commit 5276973224
4 changed files with 54 additions and 18 deletions

View File

@@ -154,18 +154,8 @@ end
dofile('main.lua')
do
local next, setmetatable, stderr = next, setmetatable, io.stderr
-- track collections
local mt = {}
-- each time a table is collected, remark it for finalization
-- on next cycle
mt.__gc = function (o)
stderr:write'.' -- mark progress
local n = setmetatable(o, mt) -- remark it
end
local n = setmetatable({}, mt) -- create object
end
-- trace GC cycles
require"tracegc".start()
report"gc.lua"
local f = assert(loadfile('gc.lua'))