diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-11-26 13:31:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-11-26 13:31:00 +0100 |
commit | 82a9d3d7e785ad838f8c6d0e5d779947be0c359f (patch) | |
tree | 33ca4e34e44b085340a44436441e42798468edcc /tex/context/base/node-tra.lua | |
parent | a57ab2d223a7bcc8e9ae57e148c30ac6e91fafdb (diff) | |
download | context-82a9d3d7e785ad838f8c6d0e5d779947be0c359f.tar.gz |
beta 2012.11.26 13:31
Diffstat (limited to 'tex/context/base/node-tra.lua')
-rw-r--r-- | tex/context/base/node-tra.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index 7d5630eaa..1d7a19896 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -16,6 +16,7 @@ local concat = table.concat local format, match, gmatch, concat, rep = string.format, string.match, string.gmatch, table.concat, string.rep local lpegmatch = lpeg.match local write_nl = texio.write_nl +local clock = os.gettimeofday or os.clock -- should go in environment local report_nodes = logs.reporter("nodes","tracing") @@ -799,3 +800,57 @@ nodes.visualizers = { } function nodes.visualizers.handler(head) return head, false end + +-- also moved here + +local snapshots = { } +nodes.snapshots = snapshots + +local nodeusage = nodepool.usage + +local lasttime = clock() +local samples = { } +local parameters = { + "cs_count", + "dyn_used", + "elapsed_time", + "luabytecode_bytes", + "luastate_bytes", + "max_buf_stack", + "obj_ptr", + "pdf_mem_ptr", + "pdf_mem_size", + "pdf_os_cntr", +-- "pool_ptr", -- obsolete + "str_ptr", +} + +function snapshots.takesample(comment) + local c = clock() + local t = { + elapsed_time = c - lasttime, + node_memory = nodeusage(), + comment = comment, + } + for i=1,#parameters do + local parameter = parameters[i] + local ps = status[parameter] + if ps then + t[parameter] = ps + end + end + samples[#samples+1] = t + lasttime = c +end + +function snapshots.getsamples() + return samples -- one return value ! +end + +function snapshots.resetsamples() + samples = { } +end + +function snapshots.getparameters() + return parameters +end |