summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-24 20:46:14 +0000
committerKarl Berry <karl@freefriends.org>2020-09-24 20:46:14 +0000
commit2e1f687d46764061ec8df089e40b9ac1aece2761 (patch)
treeb633d8a205fd529be57878fc2502e2c07a4c5efc /Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx
parentc0e73acce7eb5e03fceb4e011fa579a5706460c2 (diff)
l3 (24sep20)
git-svn-id: svn://tug.org/texlive/trunk@56424 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx33
1 files changed, 25 insertions, 8 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx b/Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx
index 370723ec90d..eb67ec98760 100644
--- a/Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx
+++ b/Master/texmf-dist/source/latex/l3experimental/l3benchmark/l3benchmark.dtx
@@ -46,7 +46,7 @@
% }^^A
% }
%
-% \date{Released 2020-09-11}
+% \date{Released 2020-09-24}
%
% \maketitle
%
@@ -129,7 +129,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesExplPackage{l3benchmark}{2020-09-11}{}
+\ProvidesExplPackage{l3benchmark}{2020-09-24}{}
{L3 Experimental benchmarking}
% \end{macrocode}
%
@@ -139,7 +139,7 @@
%<@@=sys>
% \end{macrocode}
%
-% \begin{macro}[EXP]{\sys_timer:}
+% \begin{macro}[EXP]{\sys_timer:, \@@_elapsedtime:, \@@_resettimer:}
% \begin{macro}[EXP,pTF]{\sys_if_timer_exist:}
% In \LuaTeX{}, use emulation (see \pkg{l3luatex}),
% otherwise try to locate the primitive. The
@@ -147,8 +147,27 @@
% \begin{macrocode}
\sys_if_engine_luatex:TF
{
+ \cs_new:Npn \@@_elapsedtime: { }
+ \cs_new:Npn \@@_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'@@_elapsedtime:'
+ lua.get_functions_table()[id] = function()
+ write(tointeger((gettimeofday() - epoch)*65536 // 1))
+ end~
+ token.set_lua('@@_elapsedtime:', id, 'global')
+ id = luatexbase.new_luafunction'@@_resettimer:'
+ lua.get_functions_table()[id] = function()
+ epoch = gettimeofday()
+ end~
+ token.set_lua('@@_resettimer:', id, 'global', 'protected')
+ }
\cs_new:Npn \sys_timer:
- { \lua_now:n { l3kernel.elapsedtime() } }
+ { \@@_elapsedtime: }
}
{
\cs_if_exist:NT \tex_elapsedtime:D
@@ -163,8 +182,7 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\sys_gzero_timer:, \@@_timer_fp:}
-% \begin{variable}{\g_@@_timer_base_fp}
+% \begin{macro}{\sys_gzero_timer:}
% Three case, and in each case we define \cs{sys_gzero_timer:}.
% \begin{macrocode}
\cs_if_exist:NTF \sys_timer:
@@ -172,7 +190,7 @@
\sys_if_engine_luatex:TF
{
\cs_new_protected:Npn \sys_gzero_timer:
- { \lua_now:n { l3kernel.resettimer() } }
+ { \@@_resettimer: }
}
{ \cs_new_protected:Npn \sys_gzero_timer: { \tex_resettimer:D } }
}
@@ -198,7 +216,6 @@
}
}
% \end{macrocode}
-% \end{variable}
% \end{macro}
%
% \subsection{Benchmarking code}