[Tex/LaTex] way to find out how long it took for the document to compile

compiling

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).

Best Answer

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.