diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-07-23 20:11:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-07-23 20:11:00 +0200 |
commit | 3edfc2fc3e569201a16c63871aae121e57673539 (patch) | |
tree | 77c2fab43ff04bc1dd3d89a577e855a66c38d7e8 /tex/context/base/trac-inf.lua | |
parent | b32da8747292384893ea07a0a5659b24eb216c10 (diff) | |
download | context-3edfc2fc3e569201a16c63871aae121e57673539.tar.gz |
stable 2009.07.23 20:11
Diffstat (limited to 'tex/context/base/trac-inf.lua')
-rw-r--r-- | tex/context/base/trac-inf.lua | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/tex/context/base/trac-inf.lua b/tex/context/base/trac-inf.lua index d83dc8d2f..3dfaf7119 100644 --- a/tex/context/base/trac-inf.lua +++ b/tex/context/base/trac-inf.lua @@ -19,27 +19,34 @@ statistics.threshold = 0.05 local clock = os.gettimeofday or os.clock +local notimer + function statistics.hastimer(instance) return instance and instance.starttime end function statistics.starttiming(instance) - if instance then - local it = instance.timing - if not it then - it = 0 - end - if it == 0 then - instance.starttime = clock() - if not instance.loadtime then - instance.loadtime = 0 - end + if not instance then + notimer = { } + instance = notimer + end + local it = instance.timing + if not it then + it = 0 + end + if it == 0 then + instance.starttime = clock() + if not instance.loadtime then + instance.loadtime = 0 end - instance.timing = it + 1 end + instance.timing = it + 1 end function statistics.stoptiming(instance, report) + if not instance then + instance = notimer + end if instance then local it = instance.timing if it > 1 then @@ -63,10 +70,16 @@ function statistics.stoptiming(instance, report) end function statistics.elapsedtime(instance) + if not instance then + instance = notimer + end return format("%0.3f",(instance and instance.loadtime) or 0) end function statistics.elapsedindeed(instance) + if not instance then + instance = notimer + end local t = (instance and instance.loadtime) or 0 return t > statistics.threshold end |