From 5f000ef19e7e06a5e31b1afd87d7d5654be36fc9 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 18 Jul 2009 18:26:44 +0000 Subject: [PATCH] libs/core: record peak values in luci.debug --- libs/core/luasrc/debug.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- 2.25.1