From: Jo-Philipp Wich Date: Sat, 18 Jul 2009 18:26:44 +0000 (+0000) Subject: libs/core: record peak values in luci.debug X-Git-Tag: 0.10.0~1336 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5f000ef19e7e06a5e31b1afd87d7d5654be36fc9;p=oweals%2Fluci.git libs/core: record peak values in luci.debug --- diff --git a/libs/core/luasrc/debug.lua b/libs/core/luasrc/debug.lua index d64700e0e..3969254a9 100644 --- a/libs/core/luasrc/debug.lua +++ b/libs/core/luasrc/debug.lua @@ -9,15 +9,19 @@ __file__ = debug.getinfo(1, 'S').source:sub(2) function trap_memtrace(flags, dest) flags = flags or "clr" local tracefile = io.open(dest or "/tmp/memtrace", "w") + local peak = 0 local function trap(what, line) local info = debug.getinfo(2, "Sn") + if collectgarbage("count") > peak then + peak = collectgarbage("count") + end if tracefile then tracefile:write( "[", what, "] ", info.source, ":", (line or "?"), "\t", (info.namewhat or ""), "\t", (info.name or ""), "\t", - collectgarbage("count"), "\n" + collectgarbage("count"), " (", peak, ")\n" ) end end