TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For some reason my document takes very long to compile, and I would like to narrow down why this happens. Finding the bottleneck would be greatly eased if I could time how long individual sections in the code take to compile.

The first and obvious question is: (1) Is there a 'profiler' package that returns how long parts of my documents take to compile?
Such a package should record, for example, how long individual Ti k Z pictures take to compile.

If this should not be an option, I have a second question: (2) Is it possible to output statements into the terminal?
If there was something like a command "shellout(print "Now compiling PGF Plot of weather data..."), that would print a statement in the terminal among all those LaTeX warnings I get, I could at least stop the time myself.

share|improve this question
I have no answer for (1). About (2), you can add the line \typeout{Now compiling PGF Plot of weather data...} in the right point in your document. In this way that line will be printed in the .log file and you should be able to see it in the terminal. – karlkoeller Oct 2 '13 at 10:05
you can use \message to output things on the terminal. – jfbu Mar 15 '14 at 22:09
up vote 1 down vote accepted

You could insert a line \typeout{START TRACING}\tracingmacros1 at the start of the sub-part of interest in the latex document, and then \typeout{STOP TRACING}\tracingmacros0at the end of the stuff. This will sometimes considerably slow down the compilation, but once it is done, go to the log file and ask your editor to report the number of lines from START TRACING to STOP TRACING. This line count will give a rough idea of the time taken up by that part of the source. But you need to repeat for another part to compare.

You could also do this simultaneously for various sub-regions of the source, and then compare the line counts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.