1
% !TeX TS-program = xelatex
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\tex_resettimer:D
\int_step_inline:nnn { 1 } { 1000 }
  {
    #1\tex_par:D
  }
\message{\fp_eval:n{\sys_timer:/65536}s}
\newpage
\tex_resettimer:D
\int_step_inline:nnn { 1 } { 1000 }
  {
    #1\tex_par:D
  }
\message{\fp_eval:n{\sys_timer:/65536}s}
\ExplSyntaxOff
\end{document}

Compiling this with texlive 2022, Windows 10 results in

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
[17] [18] [19] [20] [21] 1.22698974609375s [22] [23] [24] [25] [26] [27]
[28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42]
[43] 0.037994384765625s [44]

The specific time value varies, but the first loop always costs about 30 times the one of the second loop.

4
  • 1
    More seriously: The difference you are seeing is likely the overhead of starting the output to the PDF file. If you write 1\tex_par:D\newpage just before the first \tex_resettimer:D, then the two measurements get much closer (tested on Linux, but I believe Windows won't be too far off) Jul 14, 2022 at 13:19
  • Orz... Unlike this mwe, the test was not on the first page when I first met this problem. And the measurements is almost the same on Arch Linux. Jul 14, 2022 at 13:23
  • @PhelypeOleinik it is curious. With pdflatex adding a page before is enough to get similar values. But xelatex requires something more. E.g. \lipsum[1-3] on the first page works and drops the value, but \lipsum[1-2] doesn't. Jul 14, 2022 at 13:50

0

You must log in to answer this question.

Browse other questions tagged .