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.

  • 4
    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. – user4686 Mar 15 '14 at 22:09

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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