I was thinking it'd be nice to know how much time each package I load adds on to the total time between clicking "compile" and seeing the PDF come up on my screen, so that I can figure out which ones I shouldn't load unless necessary. If there were a way of measuring the precise amount of time it takes to compile (i.e., have the computer measure it, not try to approximate it by hand with a stopwatch), I can just remove one package at a time and measure the differences. But I can't find a way of doing this; I hunted around in the "log" file and didn't see this info, and I couldn't find any packages that add this functionality.

Ultimately, I admit it's not that big of a deal - compiling usually only takes a second, maybe two - but now I'm curious how to do this, and it could be relevant in much larger documents (with longer compile times).


This is somewhat OS dependent. On Linux and OS X you can use the time command from the command line.

time pdflatex myfile.tex

returns: (e.g.)

real    0m1.976s
user    0m0.331s
sys     0m0.091s

There may be a similar command in Windows. Depending on your editing environment, you can probably modify the latex command from within the editor (temporarily) to run the time command when you compile, which would make checking the times for different package configurations easier.

  • Thanks for your answer! As I should have mentioned in my question, I'm using TeXnicCenter on Windows, and I'm afraid I don't have any experience running LaTeX (or anything else) from a command line. But I suppose this is good motivation to figure that out :) When you say "modify the latex command", how would I do that in something like TeXnicCenter? – Zev Chonoles Aug 30 '11 at 23:04
  • 2
    @Zev since Windows doesn't have an exact parallel to the unix time command, it's not so obvious how to do this in Windows. There are a bunch of suggestions here: How to measure execution time of command in Windows command line. I don't know how easy any of these would be to integrate with TeXnicCenter. – Alan Munn Aug 30 '11 at 23:18
  • Ah, thanks for the link - I suppose it might be more involved to do then. – Zev Chonoles Aug 31 '11 at 2:47

By default ConTeXt gives

system          | total runtime: 35.093

at the end of each compile. This is the cumulative for all the runs needed to resolve references, etc. For more detailed usage, there is a timing module, which gives a graphical output of the resources used per page.


The output is similar to the graphs shown in Chapter XIX of the Mk manual.

  • 6
    Is there anything that ConTeXt can't do? :-) – Alan Munn Aug 30 '11 at 21:08
  • It can't reach the mass for now (I'd like to know why). – ℝaphink Aug 30 '11 at 21:50
  • Thank you for your answer! I'm not sure that ConTeXt is right for me; I'm mainly using LaTeX to type my math homework, and I don't think I need anything fancy (or at least, the discussion here mainly went over my head or wasn't important to me). But it's good to know that this ability exists elsewhere. – Zev Chonoles Aug 30 '11 at 23:14

If you are using the pdftex engine, you can measure the time that each package takes to be loaded by adding the following near the start of your document.

  {\typeout{\strip@pt\dimexpr\pdfelapsedtime sp\relax sec.}}

You could also hook similarly at the end of the document with Heiko Oberdiek's atveryend package: \AtVeryVeryEnd{\typeoutthetime}.


The regstats package with option "timer" gives the time needed for the specific (pdflatex) compilation run, using \pdfelapsedtime.

%% When compiling with lua(la)tex (and wanting to use option timer=true)
%% the following line must be uncommented (i.e. remove the "%% ").
%% \directlua{starttime = os.clock()}
When option \verb|timer| (or \verb|timer=true|) is chosen, also the time
needed for the compilation run is given. The used \verb|\pdfelapsedtime|
is not available, when lua(la)tex is used instead of pdf(la)tex to compile
the document. In that case at the very beginning of your TeX file say
\verb|\directlua{starttime = os.clock()}|
(even before \verb|\documentclass|!), and the timer option can also be
used with lua(la)tex. When neither lua(la)tex nor pdf(la)tex is used
to compile the document, the timer(-option) does not work.

For the resulting message, please compile and have a look at the end
of the log-file.

Because the compilation time for this example is usually quite short,
option \texttt{timer} is not demonstrated very spectacular.

TeX, LaTeX and all its distributives offer (at least since version 3)
a compilation command -time-statistics.

(You can find a list of compilation options and commands,
by opening a command line and execute latex --help.)

Not sure though, wether (and how) one may invoke this compilation command directly from .tex files.
Compare for example \batchmode to invoke -interaction=batchmode.

Still hope this may be useful to someone. :)

Besides, here's what its execution looks like: enter image description here

  • This is probably only for MiKTeX. There's no such option in TeX Live binaries. – egreg Sep 11 '18 at 16:07
  • Ahhh that is too bad. (Just found it and seemed useful.) Do you think I should adjust the answer then? – C-Star-W-Star Sep 11 '18 at 16:08
  • +1 I just checked, on MikTeX the order is available, elsewhere, I don't know. – AndréC Sep 11 '18 at 19:51
  • @AndréC: Thanks for checking! Yes,it seems weird since it isn't clear wether this is a MikTex specific command, or Tex command.. – C-Star-W-Star Sep 13 '18 at 0:25

You need to download timeit from Windows 2003 Resource Kit. Then run in Windows command line:

timeit xelatex.exe -synctex=1 -interaction=nonstopmode C:\Users\USERNAME\test_directory\test.tex. 

It worked on Windows 10

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.