diff options
author | Norbert Preining <preining@logic.at> | 2019-02-24 15:12:57 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2019-02-24 15:12:57 +0000 |
commit | 1314fbe93790c501dc436a5cf99f106b9e5c0f63 (patch) | |
tree | 04dc7734c8be8ffe385d41f4388826ef5857b6f9 /Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua | |
parent | eb80ce7b34f59896a1dfee5ca422495394d6677f (diff) |
Revert "ConTeXt version 2019.02.22 19:35"
This reverts commit 5c6357cdb820b4f628d036ba7b2248f221d50c0b.
git-svn-id: svn://tug.org/texlive/trunk@50112 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua | 87 |
1 files changed, 55 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua index 89f2fa0eeb1..c568b92a3f1 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua @@ -11,29 +11,46 @@ local format, concat = string.format, table.concat local settings_to_hash = utilities.parsers.settings_to_hash local formatters = string.formatters -local report_metapost = logs.reporter ("metapost") -local status_metapost = logs.messenger("metapost") +local report_metapost = logs.reporter("metapost") -local starttiming = statistics.starttiming -local stoptiming = statistics.stoptiming +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming -local trace_graphic = false +local mplib = mplib -trackers.register("metapost.graphics", - function(v) trace_graphic = v end -); +metapost = metapost or { } +local metapost = metapost +local context = context -local mplib = mplib +local setters = tokens.setters +local setmacro = setters.macro +local implement = interfaces.implement -metapost = metapost or { } -local metapost = metapost -local context = context +local v_no = interfaces.variables.no -local setters = tokens.setters -local setmacro = setters.macro -local implement = interfaces.implement +metapost.defaultformat = "metafun" +metapost.defaultinstance = "metafun" +metapost.defaultmethod = "default" -local v_no = interfaces.variables.no +local function setmpsformat(specification) + local instance = specification.instance + local format = specification.format + local method = specification.method + if not instance or instance == "" then + instance = metapost.defaultinstance + specification.instance = instance + end + if not format or format == "" then + format = metapost.defaultformat + specification.format = format + end + if not method or method == "" then + method = metapost.defaultmethod + specification.method = method + end + specification.mpx = metapost.format(instance,format,method) + return specification +end local extensiondata = metapost.extensiondata or storage.allocate { } metapost.extensiondata = extensiondata @@ -79,6 +96,9 @@ implement { arguments = "string" } +local report_metapost = logs.reporter ("metapost") +local status_metapost = logs.messenger("metapost") + local patterns = { "meta-imp-%s.mkiv", "meta-imp-%s.tex", @@ -172,9 +192,7 @@ implement { -- or just move the scanners to pps function metapost.graphic(specification) - metapost.pushformat(specification) - metapost.graphic_base_pass(specification) - metapost.popformat() + metapost.graphic_base_pass(setmpsformat(specification)) end function metapost.startgraphic(t) @@ -190,6 +208,9 @@ function metapost.startgraphic(t) if not t.method then t.method = metapost.defaultmethod end + if not t.definitions then + t.definitions = "" + end t.data = { } return t end @@ -197,10 +218,8 @@ end function metapost.stopgraphic(t) if t then t.data = concat(t.data or { },"\n") - if trace_graphic then - report_metapost("\n"..t.data.."\n") - end metapost.graphic(t) + t.data = "" end end @@ -246,7 +265,8 @@ implement { } function metapost.getclippath(specification) -- why not a special instance for this - local mpx = metapost.pushformat(specification) + setmpsformat(specification) + local mpx = specification.mpx local data = specification.data or "" if mpx and data ~= "" then starttiming(metapost) @@ -265,10 +285,7 @@ function metapost.getclippath(specification) -- why not a special instance for t result = metapost.filterclippath(result) end stoptiming(metapost) - metapost.pushformat() return result - else - metapost.pushformat() end end @@ -320,17 +337,23 @@ implement { } } -statistics.register("metapost", function() +statistics.register("metapost processing time", function() local n = metapost.n if n and n > 0 then + local nofconverted = metapost.makempy.nofconverted local elapsedtime = statistics.elapsedtime - local elapsed = statistics.elapsed - local instances, - memory = metapost.getstatistics(true) - return format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %i, memory: %0.3f M", + local elapsed = statistics.elapsed + local instances, memory = metapost.getstatistics(true) + local str = format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, memory: %0.3f M", elapsedtime(metapost), elapsedtime(mplib), elapsedtime(metapost.exectime), n, elapsedtime((elapsed(metapost) + elapsed(mplib) + elapsed(metapost.exectime)) / n), - instances, metapost.nofscriptruns(),memory/(1024*1024)) + instances, memory/(1024*1024)) + if nofconverted > 0 then + return format("%s, external: %s (%s calls)", + str, elapsedtime(metapost.makempy), nofconverted) + else + return str + end else return nil end |