From f80bd84852e9ab62fbe55e028d9ecacade4f8bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 3 Feb 2022 15:02:50 +0100 Subject: [PATCH] integrate benchmarking properly --- src/environments/groupthm/groupthm.dtx | 89 +++++++++++++++++++------- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/src/environments/groupthm/groupthm.dtx b/src/environments/groupthm/groupthm.dtx index 943b9e9..05781b2 100644 --- a/src/environments/groupthm/groupthm.dtx +++ b/src/environments/groupthm/groupthm.dtx @@ -5,7 +5,7 @@ \keepsilent \usedir{tex/latex/mkessler/groupthm} \askforoverwritefalse -\generate{\file{groupthm.sty}{\from{groupthm.dtx}{package}}} +\generate{\file{groupthm.sty}{\from{groupthm.dtx}{package,benchmark}}} \def\tmpa{plain} \ifx\tmpa\fmtname\endgroup\expandafter\bye\fi \endgroup @@ -836,6 +836,9 @@ % \begin{macrocode} \RequirePackage{amsthm} \RequirePackage{thmtools} +%<*benchmark> +\RequirePackage{l3benchmark} +% \RequirePackage{l3keys2e} % \end{macrocode} % @@ -2782,12 +2785,18 @@ % \begin{macrocode} \hook_gput_code:nnn { enddocument } { groupthm } { +%<*benchmark> + \@@_benchmark_once:nn + { + Benchmarking ~ writing ~ to ~ auxfile: + } + { +% % \end{macrocode} % First, perform the regular dump: % \begin{macrocode} - \clist_map_function:NN \g_@@_dump_auxfile_clist - \_@@_write_auxout:n - + \clist_map_function:NN \g_@@_dump_auxfile_clist + \_@@_write_auxout:n % \end{macrocode} % Now, we want to dump the cached clist, but wrap it into the % the corresponding macro call for storing it in @@ -2795,22 +2804,24 @@ % For this, we have to put two single braces into the auxfile % separately % \begin{macrocode} - \_@@_write_auxout:n - { - \csname tl_gput_right:cn \endcsname - { - g_@@_lazy_auxfile_tl - } - } - \_@@_write_auxout:x { \str_use:N \c_left_brace_str } + \_@@_write_auxout:n + { + \csname tl_gput_right:cn \endcsname + { + g_@@_lazy_auxfile_tl + } + } + \_@@_write_auxout:x { \str_use:N \c_left_brace_str } % \end{macrocode} % Now, dump the list % \begin{macrocode} - \clist_map_function:NN \g_@@_dump_cache_clist - \_@@_write_auxout:n - - \_@@_write_auxout:x { \str_use:N \c_right_brace_str } + \clist_map_function:NN \g_@@_dump_cache_clist + \_@@_write_auxout:n + \_@@_write_auxout:x { \str_use:N \c_right_brace_str } +%<*benchmark> } +% + } % \end{macrocode} @@ -2897,14 +2908,30 @@ \int_compare:nNnTF \g_@@_cache_version_aux_int < \g_@@_cache_version_document_int { +%<*benchmark> + \@@_benchmark_once:nn + { + Benchmarking ~ declarations ~ of ~ theorems ~ from ~ document: + } + { +% \tl_use:N \g_@@_lazy_document_tl +%<*benchmark> + } +% } { - \exp_args:NNV \iow_now:Nn \l_my_iow \g_@@_lazy_auxfile_tl - \benchmark_once:n - { - \tl_use:N \g_@@_lazy_auxfile_tl - } +%<*benchmark> + \@@_benchmark_once:nn + { + Benchmarking ~ declarations ~ of ~ theorems ~ from ~ aux ~ file: + } + { +% + \tl_use:N \g_@@_lazy_auxfile_tl +%<*benchmark> + } +% } } % \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} -% +%<*benchmark> +\cs_new:Npn \@@_benchmark_once:nn #1 + { + \iow_term:n { [groupthm] ~ #1 } + \iow_log:n { [groupthm] ~ #1 } + \benchmark_once:n + } +% % \end{macrocode} +% \end{macro} +% +% % % % \begin{macrocode}