diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua index 7a5c35fd5fa..0a4537e3177 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua @@ -29,7 +29,7 @@ statistics.threshold = 0.01 local statusinfo, n, registered, timers = { }, 0, { }, { } setmetatableindex(timers,function(t,k) - local v = { timing = 0, loadtime = 0 } + local v = { timing = 0, loadtime = 0, offset = 0 } t[k] = v return v end) @@ -39,7 +39,7 @@ local function hastiming(instance) end local function resettiming(instance) - timers[instance or "notimer"] = { timing = 0, loadtime = 0 } + timers[instance or "notimer"] = { timing = 0, loadtime = 0, offset = 0 } end local ticks = clock @@ -118,12 +118,27 @@ local function stoptiming(instance) return 0 end +local function benchmarktimer(instance) + local timer = timers[instance or "notimer"] + local it = timer.timing + if it > 1 then + timer.timing = it - 1 + else + local starttime = timer.starttime + if starttime and starttime > 0 then + timer.offset = ticks() - starttime + else + timer.offset = 0 + end + end +end + local function elapsed(instance) if type(instance) == "number" then return instance else local timer = timers[instance or "notimer"] - return timer and seconds(timer.loadtime) or 0 + return timer and seconds(timer.loadtime - 2*(timer.offset or 0)) or 0 end end @@ -138,7 +153,7 @@ local function currenttime(instance) else local starttime = timer.starttime if starttime and starttime > 0 then - return seconds(timer.loadtime + ticks() - starttime) + return seconds(timer.loadtime + ticks() - starttime - 2*(timer.offset or 0)) end end return 0 @@ -168,6 +183,7 @@ statistics.elapsed = elapsed statistics.elapsedtime = elapsedtime statistics.elapsedindeed = elapsedindeed statistics.elapsedseconds = elapsedseconds +statistics.benchmarktimer = benchmarktimer -- general function .. we might split this module @@ -193,10 +209,17 @@ function statistics.show() -- register("luatex banner", function() -- return lower(status.banner) -- end) - register("used engine", function() - return format("%s version %s with functionality level %s, banner: %s", - LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, lower(status.banner)) - end) + if LUATEXENGINE == "luametatex" then + register("used engine", function() + return format("%s version %s, functionality level %s, format id %s", + LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, LUATEXFORMATID) + end) + else + register("used engine", function() + return format("%s version %s with functionality level %s, banner: %s", + LUATEXENGINE, LUATEXVERSION, LUATEXFUNCTIONALITY, lower(status.banner)) + end) + end register("control sequences", function() return format("%s of %s + %s", status.cs_count, status.hash_size,status.hash_extra) end) @@ -214,13 +237,11 @@ function statistics.show() -- collectgarbage("collect") register("lua properties",function() local hashchar = tonumber(status.luatex_hashchars) - local hashtype = status.luatex_hashtype local mask = lua.mask or "ascii" - return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)", + return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)", jit and "luajit" or "lua", LUAVERSION, statistics.memused(), - hashtype or "default", hashchar and 2^hashchar or "unknown", mask, mask == "utf" and "τεχ" or "tex") |