libs/core: record peak values in luci.debug
This commit is contained in:
parent
08840ce7d5
commit
5f000ef19e
1 changed files with 5 additions and 1 deletions
|
@ -9,15 +9,19 @@ __file__ = debug.getinfo(1, 'S').source:sub(2)
|
||||||
function trap_memtrace(flags, dest)
|
function trap_memtrace(flags, dest)
|
||||||
flags = flags or "clr"
|
flags = flags or "clr"
|
||||||
local tracefile = io.open(dest or "/tmp/memtrace", "w")
|
local tracefile = io.open(dest or "/tmp/memtrace", "w")
|
||||||
|
local peak = 0
|
||||||
|
|
||||||
local function trap(what, line)
|
local function trap(what, line)
|
||||||
local info = debug.getinfo(2, "Sn")
|
local info = debug.getinfo(2, "Sn")
|
||||||
|
if collectgarbage("count") > peak then
|
||||||
|
peak = collectgarbage("count")
|
||||||
|
end
|
||||||
if tracefile then
|
if tracefile then
|
||||||
tracefile:write(
|
tracefile:write(
|
||||||
"[", what, "] ", info.source, ":", (line or "?"), "\t",
|
"[", what, "] ", info.source, ":", (line or "?"), "\t",
|
||||||
(info.namewhat or ""), "\t",
|
(info.namewhat or ""), "\t",
|
||||||
(info.name or ""), "\t",
|
(info.name or ""), "\t",
|
||||||
collectgarbage("count"), "\n"
|
collectgarbage("count"), " (", peak, ")\n"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue