diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/trac-inf.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/trac-inf.lua | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/context/base/trac-inf.lua b/Master/texmf-dist/tex/context/base/trac-inf.lua index 3dfaf71192b..72f03675a1c 100644 --- a/Master/texmf-dist/tex/context/base/trac-inf.lua +++ b/Master/texmf-dist/tex/context/base/trac-inf.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['trac-inf'] = { version = 1.001, - comment = "companion to luat-lib.tex", + comment = "companion to trac-inf.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -25,6 +25,14 @@ function statistics.hastimer(instance) return instance and instance.starttime end +function statistics.resettiming(instance) + if not instance then + notimer = { timing = 0, loadtime = 0 } + else + instance.timing, instance.loadtime = 0, 0 + end +end + function statistics.starttiming(instance) if not instance then notimer = { } @@ -39,6 +47,8 @@ function statistics.starttiming(instance) if not instance.loadtime then instance.loadtime = 0 end + else +--~ logs.report("system","nested timing (%s)",tostring(instance)) end instance.timing = it + 1 end @@ -84,6 +94,12 @@ function statistics.elapsedindeed(instance) return t > statistics.threshold end +function statistics.elapsedseconds(instance,rest) -- returns nil if 0 seconds + if statistics.elapsedindeed(instance) then + return format("%s seconds %s", statistics.elapsedtime(instance),rest or "") + end +end + -- general function function statistics.register(tag,fnc) @@ -161,3 +177,21 @@ function statistics.timed(action,report) statistics.stoptiming(timer) report("total runtime: %s",statistics.elapsedtime(timer)) end + +-- where, not really the best spot for this: + +commands = commands or { } + +local timer + +function commands.resettimer() + statistics.resettiming(timer) + statistics.starttiming(timer) +end + +function commands.elapsedtime() + statistics.stoptiming(timer) + tex.sprint(statistics.elapsedtime(timer)) +end + +commands.resettimer() |