diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-02-17 10:31:56 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-02-17 10:31:56 +0100 |
commit | b14f992ef5f4e868c9959b174278c86516d60dbc (patch) | |
tree | 28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/trac-inf.lua | |
parent | 95a1799032dc61dbca4a11e495be34b4397c8fec (diff) | |
download | context-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz |
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/trac-inf.lua')
-rw-r--r-- | tex/context/base/mkiv/trac-inf.lua | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/tex/context/base/mkiv/trac-inf.lua b/tex/context/base/mkiv/trac-inf.lua index 12a4f646f..2aecb6703 100644 --- a/tex/context/base/mkiv/trac-inf.lua +++ b/tex/context/base/mkiv/trac-inf.lua @@ -42,11 +42,53 @@ local function resettiming(instance) timers[instance or "notimer"] = { timing = 0, loadtime = 0 } end +local ticks = clock +local seconds = function(n) return n or 0 end + +-- local okay, ffi = pcall(require,"ffi") +-- +-- if ffi and os.type == "windows" then +-- +-- local okay, kernel = pcall(ffi.load,"kernel32") +-- +-- if kernel then +-- +-- local tonumber = ffi.number or tonumber +-- +-- ffi.cdef[[ +-- int QueryPerformanceFrequency(int64_t *lpFrequency); +-- int QueryPerformanceCounter(int64_t *lpPerformanceCount); +-- ]] +-- +-- local target = ffi.new("__int64[1]") +-- +-- ticks = function() +-- if kernel.QueryPerformanceCounter(target) == 1 then +-- return tonumber(target[0]) +-- else +-- return 0 +-- end +-- end +-- +-- local target = ffi.new("__int64[1]") +-- +-- seconds = function(ticks) +-- if kernel.QueryPerformanceFrequency(target) == 1 then +-- return ticks / tonumber(target[0]) +-- else +-- return 0 +-- end +-- end +-- +-- end +-- +-- end + local function starttiming(instance) local timer = timers[instance or "notimer"] local it = timer.timing or 0 if it == 0 then - timer.starttime = clock() + timer.starttime = ticks() if not timer.loadtime then timer.loadtime = 0 end @@ -62,7 +104,7 @@ local function stoptiming(instance) else local starttime = timer.starttime if starttime and starttime > 0 then - local stoptime = clock() + local stoptime = ticks() local loadtime = stoptime - starttime timer.stoptime = stoptime timer.loadtime = timer.loadtime + loadtime @@ -79,7 +121,7 @@ local function elapsed(instance) return instance or 0 else local timer = timers[instance or "notimer"] - return timer and timer.loadtime or 0 + return timer and seconds(timer.loadtime) or 0 end end @@ -137,10 +179,13 @@ function statistics.show() local total, indirect = status.callbacks or 0, status.indirect_callbacks or 0 return format("%s direct, %s indirect, %s total", total-indirect, indirect, total) end) - if jit then - local jitstatus = { jit.status() } - if jitstatus[1] then - register("luajit options", concat(jitstatus," ",2)) + if TEXENGINE == "luajittex" and JITSUPPORTED then + local jitstatus = jit.status + if jitstatus then + local jitstatus = { jitstatus() } + if jitstatus[1] then + register("luajit options", concat(jitstatus," ",2)) + end end end -- so far |