integrate benchmarking properly

This commit is contained in:
Maximilian Keßler 2022-02-03 15:02:50 +01:00
parent 7fe4092d8e
commit f80bd84852

View file

@ -5,7 +5,7 @@
\keepsilent \keepsilent
\usedir{tex/latex/mkessler/groupthm} \usedir{tex/latex/mkessler/groupthm}
\askforoverwritefalse \askforoverwritefalse
\generate{\file{groupthm.sty}{\from{groupthm.dtx}{package}}} \generate{\file{groupthm.sty}{\from{groupthm.dtx}{package,benchmark}}}
\def\tmpa{plain} \def\tmpa{plain}
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi \ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
\endgroup \endgroup
@ -836,6 +836,9 @@
% \begin{macrocode} % \begin{macrocode}
\RequirePackage{amsthm} \RequirePackage{amsthm}
\RequirePackage{thmtools} \RequirePackage{thmtools}
%<*benchmark>
\RequirePackage{l3benchmark}
%</benchmark>
\RequirePackage{l3keys2e} \RequirePackage{l3keys2e}
% \end{macrocode} % \end{macrocode}
% %
@ -2782,12 +2785,18 @@
% \begin{macrocode} % \begin{macrocode}
\hook_gput_code:nnn { enddocument } { groupthm } \hook_gput_code:nnn { enddocument } { groupthm }
{ {
%<*benchmark>
\@@_benchmark_once:nn
{
Benchmarking ~ writing ~ to ~ auxfile:
}
{
%</benchmark>
% \end{macrocode} % \end{macrocode}
% First, perform the regular dump: % First, perform the regular dump:
% \begin{macrocode} % \begin{macrocode}
\clist_map_function:NN \g_@@_dump_auxfile_clist \clist_map_function:NN \g_@@_dump_auxfile_clist
\_@@_write_auxout:n \_@@_write_auxout:n
% \end{macrocode} % \end{macrocode}
% Now, we want to dump the cached clist, but wrap it into the % Now, we want to dump the cached clist, but wrap it into the
% the corresponding macro call for storing it in % the corresponding macro call for storing it in
@ -2795,22 +2804,24 @@
% For this, we have to put two single braces into the auxfile % For this, we have to put two single braces into the auxfile
% separately % separately
% \begin{macrocode} % \begin{macrocode}
\_@@_write_auxout:n \_@@_write_auxout:n
{ {
\csname tl_gput_right:cn \endcsname \csname tl_gput_right:cn \endcsname
{ {
g_@@_lazy_auxfile_tl g_@@_lazy_auxfile_tl
} }
} }
\_@@_write_auxout:x { \str_use:N \c_left_brace_str } \_@@_write_auxout:x { \str_use:N \c_left_brace_str }
% \end{macrocode} % \end{macrocode}
% Now, dump the list % Now, dump the list
% \begin{macrocode} % \begin{macrocode}
\clist_map_function:NN \g_@@_dump_cache_clist \clist_map_function:NN \g_@@_dump_cache_clist
\_@@_write_auxout:n \_@@_write_auxout:n
\_@@_write_auxout:x { \str_use:N \c_right_brace_str }
\_@@_write_auxout:x { \str_use:N \c_right_brace_str } %<*benchmark>
} }
%</benchmark>
}
% \end{macrocode} % \end{macrocode}
@ -2897,14 +2908,30 @@
\int_compare:nNnTF \int_compare:nNnTF
\g_@@_cache_version_aux_int < \g_@@_cache_version_document_int \g_@@_cache_version_aux_int < \g_@@_cache_version_document_int
{ {
%<*benchmark>
\@@_benchmark_once:nn
{
Benchmarking ~ declarations ~ of ~ theorems ~ from ~ document:
}
{
%</benchmark>
\tl_use:N \g_@@_lazy_document_tl \tl_use:N \g_@@_lazy_document_tl
%<*benchmark>
}
%</benchmark>
} }
{ {
\exp_args:NNV \iow_now:Nn \l_my_iow \g_@@_lazy_auxfile_tl %<*benchmark>
\benchmark_once:n \@@_benchmark_once:nn
{ {
\tl_use:N \g_@@_lazy_auxfile_tl Benchmarking ~ declarations ~ of ~ theorems ~ from ~ aux ~ file:
} }
{
%</benchmark>
\tl_use:N \g_@@_lazy_auxfile_tl
%<*benchmark>
}
%</benchmark>
} }
} }
% \end{macrocode} % \end{macrocode}
@ -2962,11 +2989,29 @@
% %
% %
% %
% \subsection{Benchmarking}
%
% Just some utility macro for benchmarking
% some parts of the package.
%
%
% \begin{macro}{\@@_benchmark:nn}
%
% %
% %
% \begin{macrocode} % \begin{macrocode}
% %<*benchmark>
\cs_new:Npn \@@_benchmark_once:nn #1
{
\iow_term:n { [groupthm] ~ #1 }
\iow_log:n { [groupthm] ~ #1 }
\benchmark_once:n
}
%</benchmark>
% \end{macrocode} % \end{macrocode}
% \end{macro}
%
%
% %
% %
% \begin{macrocode} % \begin{macrocode}