%%
%% This is file `regstats-example.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% regstats.dtx  (with options: `example')
%% 
%% This is a generated file.
%% 
%% Project: regstats
%% Version: 2025-01-28 v1.1b
%% Info: Counting used registers
%% 
%% Copyright (C) 2011 - 2025 by
%%     H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005-12-01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is H.-Martin Muench.
%% 
%% This work consists of the main source file regstats.dtx,
%% the README, and the derived files
%%    regstats.sty, regstats.pdf,
%%    regstats.ins, regstats.drv,
%%    regstats-example.tex, regstats-example.pdf,
%%    regstats-example.log.
%% 
%% In memoriam
%%  Claudia Simone Barth + 1996-01-30
%%  Tommy Muench         + 2014-01-02
%%  Hans-Klaus Muench    + 2014-08-24
%% 
%% When compiling with LuaLaTeX (and wanting to use option timer=true),
%% the following line must be uncommented (i.e. remove the "%% ").
%% \directlua{starttime = os.clock()}
\documentclass[british]{article}
\usepackage[left=true,timer=true]{regstats}[2025/01/28]% v1.1b Counting used registers (HMM)
\ifpdf\ifluatex\else
\pdfinfo{
  /Author (H.-Martin Muench)
  /Title (regstats package example)
  /Subject (Example for the regstats package)
  /Keywords (LaTeX;registers;read;write;language;box;dimen;count;toks;muskip;skip;counter;regstats)
}
\fi\fi
%% If you use the hyperref package, use the options of that package
%% to set the pdf information.
%% Do NOT use \pdfinfo AND the hyperref package!

%%\usepackage{etex}
%%\usepackage{morewrites}

\makeatletter
\newcommand{\stressCounter}[1]{%
  \ifnum\the\count10<#1\relax\else\message{Already \the\count10 \space counters used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count10<#1\do%
    {\advance\@tempcnta +1\relax%
     \newcounter{TestCounter\the\@tempcnta} \message{counter \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressDimen}[1]{%
  \ifnum\the\count11<#1\relax\else\message{Already \the\count11 \space dimens used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count11<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newdimen\csname TestDimen\the\@tempcnta\endcsname \message{dimen \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressSkip}[1]{\%
  \ifnum\the\count12<#1\relax\else\message{Already \the\count11 \space skips used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count12<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newskip\csname TestSkip\the\@tempcnta\endcsname \message{skip \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressMuskip}[1]{%
  \ifnum\the\count13<#1\relax\else\message{Already \the\count11 \space muskips used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count13<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newmuskip\csname TestMuskip\the\@tempcnta\endcsname \message{muskip \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressBox}[1]{%
  \ifnum\the\count14<#1\relax\else\message{Already \the\count11 \space boxes used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count14<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newbox\csname TestBox\the\@tempcnta\endcsname \message{box \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressToks}[1]{%
  \ifnum\the\count15<#1\relax\else\message{Already \the\count11 \space toks used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count15<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newtoks\csname TestToks\the\@tempcnta\endcsname \message{toks \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressRead}[1]{%
  \ifnum\the\count16<#1\relax\else\message{Already \the\count11 \space reads used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count16<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newread\csname TestRead\the\@tempcnta\endcsname \message{read \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressWrite}[1]{%
  \ifnum\the\count17<#1\relax\else\message{Already \the\count11 \space writes used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count17<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newwrite\csname TestWrite\the\@tempcnta\endcsname \message{write \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressFam}[1]{%
  \ifnum\the\count18<#1\relax\else\message{Already \the\count11 \space fams used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count18<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newfam\csname TestFam\the\@tempcnta\endcsname \message{fam \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressLanguage}[1]{%
  \ifnum\the\count19<#1\relax\else\message{Already \the\count11 \space languages used.} \fi%
  \@tempcnta=0\relax%
  \@whilenum\the\count19<#1\do%
    {\advance\@tempcnta +1\relax%
     \expandafter\newlanguage\csname TestLanguage\the\@tempcnta\endcsname \message{language \the\allocationnumber ^^J}%
    }%
  }

\newcommand{\stressInsert}[1]{%
 \message{Declaring #1\space ADDITIONAL inserts:}%
 \@tempcnta=0\relax%
 \@whilenum\the\@tempcnta<#1\do%
  {\advance\@tempcnta +1\relax%
   \expandafter\newinsert\csname TestInsert\the\@tempcnta\endcsname%
   \message{insert \the\@tempcnta: \the\allocationnumber^^J}%
  }%
 }
\makeatother

\listfiles
\begin{document}
\pagenumbering{arabic}
\section*{Example for regstats}

This example demonstrates the use of package\newline
\textsf{regstats}, v1.1b as of 2025-01-28.\newline
The used options were \texttt{left=true,timer=true}.\par
\texttt{left=false,timer=false} would be the defaults.\newline

Regarding the use of
\makeatletter%
\ \@ifundefined{eTeX}{\hbox{$\m@th \varepsilon $-\TeX}}{\eTeX}, %
\makeatother%
the \texttt{morewrite} package, the reservation of \texttt{insert}s,
and using more \texttt{math families} please see the documentation!\newline

For the resulting message, please compile \texttt{regstats-example.tex}
and have a look at the end of its \texttt{.log}-file.\newline

Because the compilation time for this example is usually quite short,
option \texttt{timer} is not demonstrated very spectacular.\newline

To test a register type for the number of available registers,
uncomment the respective line below and set the number to an interesting value.

\makeatletter
%%\stressCounter{233}
%%\stressDimen{233}
%%\stressSkip{233}
%%\stressMuskip{255}
%%\stressBox{233}
%%\stressToks{255}
%%\stressRead{15}
%%\stressWrite{14}
%%\stressFam{15}
%%\stressLanguage{255}
%%\stressInsert{20}
\makeatother

\end{document}
\endinput
%%
%% End of file `regstats-example.tex'.
