%%
%% Copyright (c) 2022-2023 by Friedemann Bartels
%%
%% This file 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.  The latest version of this license is in:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2008/05/04 or later.
%%

%%
%% Benchmark 500 pages with Apple M1: 27.3s (draft: 21.3s, layouthelper: 41.1s)
%%

\documentclass[gutter=10mm]{pagelayout}

\nocuttingmarks
% \safezone\grid\placeholders
\newtemplate{testtemplate}{
  \setgrid{
    {[1]{1}{2}{4}{8}{16}}
    {[2]{1}{2}{4}{8}{16}}
    {[4]{2}{1}{4}{8}{16}}
    {[8]{2}{1}{4}{8}{16}}
    {[16]{2}{1}{4}{8}{16}}
  }
  \placeholder{0 0 1 1}
  \placeholder{0 1 1 2}
  \placeholder{0 2 1 3}
  \placeholder{1 0 2 1}
  \placeholder{1 1 2 2}
  \placeholder{1 2 2 3}
  \placeholder{2 0 3 1}
  \setborder[width=1mm]{}
  \placeholder{2 1 3 2}
  \placeholder{2 2 3 3}
  \placeholder{4 4 5 5}
}

\newcount\runs
\runs=500

\begin{document}

  \loop
    \template{testtemplate}{
      \graphic{1x1}
      \graphic{2x1}
      \graphic[scale=2]{3x2}
      \graphic{1x2}
      \graphic{1x1}
      \graphic{2x1}
      \graphic[scale=2]{2x3}
      \graphic{1x2}
      \graphic[scale=2]{1x1}
    }
    \advance\runs by -1
  \ifnum \runs>0
  \repeat

\end{document}
