summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/core-uti.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-08-24 20:03:53 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-08-24 20:03:53 +0200
commit89f7bbac9616406b3990b8608c17c542f5fb476d (patch)
tree9e487938454fd224025391d975ae85dff85a10f8 /tex/context/base/mkiv/core-uti.lua
parent4ba731dd6ff370a42984b4df050906fd9a884bc8 (diff)
downloadcontext-89f7bbac9616406b3990b8608c17c542f5fb476d.tar.gz
2020-08-24 19:49:00
Diffstat (limited to 'tex/context/base/mkiv/core-uti.lua')
-rw-r--r--tex/context/base/mkiv/core-uti.lua82
1 files changed, 47 insertions, 35 deletions
diff --git a/tex/context/base/mkiv/core-uti.lua b/tex/context/base/mkiv/core-uti.lua
index 50c7bc9dc..1debf347b 100644
--- a/tex/context/base/mkiv/core-uti.lua
+++ b/tex/context/base/mkiv/core-uti.lua
@@ -73,10 +73,9 @@ local enabled = true
local initialized = false
directives.register("job.save",function(v) enabled = v end)
-----------.register("job.keep",function(v) kept = v end)
-function job.disablesave() -- can be command
- enabled = false
+function job.disablesave()
+ enabled = false -- for instance called when an error
end
function job.initialize(loadname,savename)
@@ -89,10 +88,7 @@ function job.initialize(loadname,savename)
end
job.load(loadname) -- has to come after structure is defined !
luatex.registerstopactions(function()
- if enabled and not status.lasterrorstring or status.lasterrorstring == "" then
- -- if kept then
- -- job.keep(loadname) -- could move to mtx-context instead
- -- end
+ if enabled then
job.save(savename)
end
end)
@@ -396,37 +392,53 @@ statistics.register("jobdata time",function()
end
end)
--- statistics.register("callbacks", function()
--- local total, indirect = status.callbacks or 0, status.indirect_callbacks or 0
--- local pages = texgetcount('realpageno') - 1
--- if pages > 1 then
--- return format("direct: %s, indirect: %s, total: %s (%i per page)", total-indirect, indirect, total, total/pages)
--- else
--- return format("direct: %s, indirect: %s, total: %s", total-indirect, indirect, total)
--- end
--- end)
-
-function statistics.callbacks()
- local c_internal = status.callbacks or 0
- local c_file = status.indirect_callbacks or 0
- local c_direct = status.direct_callbacks or 0
- local c_late = backends.noflatelua() or 0
- local c_function = status.function_callbacks or 0
- local c_total = c_internal + c_file + c_direct + c_late + c_function
- local n_pages = texgetcount('realpageno') - 1
- local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0
- local s_result = format (
- c_average > 0 and "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)"
- or "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s",
- c_internal, c_file, c_direct, c_late, c_function, c_total, c_average
- )
- statistics.callbacks = function()
- return s_result
+if CONTEXTLMTXMODE > 0 then
+
+ function statistics.callbacks()
+ local backend = backends.getcallbackstate()
+ local frontend = status.getcallbackstate()
+ local pages = structures.pages.nofpages or 0
+ local total = frontend.count + backend.count
+ local average = pages > 0 and math.round(total/pages) or 0
+ local result = format (
+ "file: %s, saved: %s, direct: %s, function: %s, value: %s, message: %s, bytecode: %s, late %s, total: %s (%s per page)",
+ frontend.file, frontend.saved, frontend.direct, frontend["function"],
+ frontend.value, frontend.message, frontend.bytecode, backend.count,
+ total, average
+ )
+ statistics.callbacks = function()
+ return result
+ end
+ return result
+ end
+
+ statistics.register("callbacks", statistics.callbacks)
+
+else
+
+ function statistics.callbacks()
+ local c_internal = status.callbacks or 0
+ local c_file = status.indirect_callbacks or 0
+ local c_direct = status.direct_callbacks or 0
+ local c_late = backends.getcallbackstate().count
+ local c_function = status.function_callbacks or 0
+ local c_total = c_internal + c_file + c_direct + c_late + c_function
+ local n_pages = structures.pages.nofpages or 0
+ local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0
+ local result = format (
+ "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)",
+ c_internal, c_file, c_direct, c_late, c_function, c_total, c_average
+ )
+ statistics.callbacks = function()
+ return result
+ end
+ return result
end
- return s_result
+
+ statistics.register("callbacks", statistics.callbacks)
+
end
-statistics.register("callbacks", statistics.callbacks)
statistics.register("randomizer", function()
if rmethod and rvalue then