diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-07-18 18:26:44 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-07-18 18:26:44 +0000 |
commit | 5f000ef19e7e06a5e31b1afd87d7d5654be36fc9 (patch) | |
tree | edde931ae842619e631ea0da07c9fb7e5f38bcce /libs | |
parent | 08840ce7d52d1fd4e593397429eb60025ab89f94 (diff) |
libs/core: record peak values in luci.debug
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/debug.lua | 6 |
1 files changed, 5 insertions, 1 deletions
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 |