The most obvious way to speed up LaTeX processing is to split a large and complex document into smaller pieces. For example, Makefiles, \beginpgfgraphicnamed/\endpgfgraphicnamed when using TiKZ, and splitting a large file into separate chapters are all helpful in splitting a large job into smaller, hopefully independent pieces. But sometimes this is not enough -- many packages do complicated things under the hood, leading to slow document processing.

Are there any tools to help isolate the culprits?

It would be great to also have the profiling tool provide suggestions on ways to speed things up.


3 Answers 3


Perhaps not quite what you're after, but the trace package is used by the LaTeX Project to get a feel for the 'cost' of different things. This package lets you include every TeX expansion and assignment in the log file. So you can check how many lines a particular function adds to the log, which gives you an idea of how hard TeX is working to do whatever you've asked for. Other than that, the approach I take is to create simple test files (say one with a loop to repeat one function many times), then use 'time' at the command line to see what changes as I alter the input.

  • Note. There's the (relatively) new l3benchmark library, although I'm not sure how to use it
    – user202729
    Mar 31, 2022 at 1:35

pdfTeX (which is the default nowadays, even if you're generating DVI) has functions for doing timing tests. Use \pdfresettime to start it off and do ‘something’ with \pdfelapsedtime when you're done:


The value of \pdfelapsedtime is the number of seconds elapsed multiplied by 65536.


tikz/pgf seems to provide a general profiler built on top of \pdfelapsedtime to optimise TeX code. See "44 Profiler Library" in its manual from a recent CVS checkout. The stable release pgf 2.0 is out of date.

  • For anyone still wondering in '21, this should probably be the accepted answer, as pgf/TikZ provide a profiler library which does exactly what OP asked. Profiling of individual commands and environments has to be declared manually but the output is provided in the log and in a special output file. This allows you to profile à la MATLAB. Aug 17, 2021 at 9:25
  • mirror.kumi.systems/ctan/graphics/pgf/base/doc/pgfmanual.pdf (currently 67 Profiler Library)
    – janniks
    Sep 17, 2021 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .