diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3experimental/l3benchmark/l3benchmark.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3experimental/l3benchmark/l3benchmark.sty | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3benchmark/l3benchmark.sty b/Master/texmf-dist/tex/latex/l3experimental/l3benchmark/l3benchmark.sty index 25891307496..c037a40a41e 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3benchmark/l3benchmark.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3benchmark/l3benchmark.sty @@ -20,12 +20,31 @@ %% %% File: l3benchmark.dtx \RequirePackage{expl3} -\ProvidesExplPackage{l3benchmark}{2020-09-11}{} +\ProvidesExplPackage{l3benchmark}{2020-09-24}{} {L3 Experimental benchmarking} \sys_if_engine_luatex:TF { + \cs_new:Npn \__sys_elapsedtime: { } + \cs_new:Npn \__sys_resettimer: { } + \lua_now:n + { + local~gettimeofday = os.gettimeofday~ + local~epoch = gettimeofday() - os.clock()~ + local~write = tex.write~ + local~tointeger = math.tointeger~ + local~id = luatexbase.new_luafunction'__sys_elapsedtime:' + lua.get_functions_table()[id] = function() + write(tointeger((gettimeofday() - epoch)*65536 // 1)) + end~ + token.set_lua('__sys_elapsedtime:', id, 'global') + id = luatexbase.new_luafunction'__sys_resettimer:' + lua.get_functions_table()[id] = function() + epoch = gettimeofday() + end~ + token.set_lua('__sys_resettimer:', id, 'global', 'protected') + } \cs_new:Npn \sys_timer: - { \lua_now:n { l3kernel.elapsedtime() } } + { \__sys_elapsedtime: } } { \cs_if_exist:NT \tex_elapsedtime:D @@ -41,7 +60,7 @@ \sys_if_engine_luatex:TF { \cs_new_protected:Npn \sys_gzero_timer: - { \lua_now:n { l3kernel.resettimer() } } + { \__sys_resettimer: } } { \cs_new_protected:Npn \sys_gzero_timer: { \tex_resettimer:D } } } |