summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-05-19 21:26:37 +0000
committerKarl Berry <karl@freefriends.org>2019-05-19 21:26:37 +0000
commit5653ce727bbbbd072f5c4e6a2d8b16a3fb4ba86f (patch)
tree82c8175883c03586d73d382ba4c2883405f60613 /Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua
parent556dfa7ef108ed2946da8b8f32106f881d064ce9 (diff)
lualibs (19may19)
git-svn-id: svn://tug.org/texlive/trunk@51167 c570f23f-e606-0410-a88d-b1316a301751
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.lua43
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")