# Tag Info

84

In the end, it is only one thing that really makes a difference: Single-Threaded CPU power! I do a lot of LaTeX compiling, especially of large beamer presentations (lecture notes with 500+ slides, lots of overlays and lots of TikZ stuff). Compilation time with three pdflatex runs usually takes minutes. I have done experiments with this setting on a bunch ...

36

This article is an astonishing piece of reckless stupidity. The test was: The participants were instructed to reproduce the source text within thirty minutes. So the hard truth is: With MS Word you can better and faster copy off your neighbor than with LaTeX. And the spell checker of Word is better than the spell checkers of the group of LaTeX users was....

30

If you are using XeLaTeX, a substantial amount of time is spent gzipping data with highest compression (9) in the xdvipdfmx command. ~$xdvipdfmx --help … -z number Set zlib compression level (0-9) [9] … For me, on a 90 page document: ~$ time xelatex -interaction=nonstopmode Thesis.tex … real 0m6.056s ~$ls -lh Thesis.pdf … 6,0M … Thesis.pdf ... 29 Running some tests and looking at the output of the process monitor I found that on windows with miktex the "feature" of fontspec to load default settings from a file with the ending .fontspec is slowing down the font search considerably as miktex is looking everywhere for the files. Disabling the feature meant for me that this document needed only around 2.... 29 The "slow" compilation speed of TeX has two main reasons: It cannot parallelize. Games, GUIs etc. (what you refer to) do use multi-threading to speed up their execution. Because TeX builds up pages gradually (with counters, …) this is not an option and there are some questions about this aspect on the site (see e.g. here), apart from those asking about ... 26 tikzexternalize in parallel I thought I might as well expand my answer a bit regarding the parallelization of externalizing tikzpictures. I recommend reading the section of pgfman for more details (p.607 onwards). Disclaimer: I'm a Linux guy; haven't tried this on other platforms. But this question suggests that it can be done, apparently. Anyway: Let's ... 26 This was quite a puzzle. This answer will be long, to match the long time it took me to get to the bottom of this, but the sections are titled and numbered so you can skip over the ones you don't care about. You can even skip to the one-sentence summary at the end. :-) 1. The debugging process This will describe how I arrived at the answer. If you don't ... 23 This question can be understood in two ways: You want to compile your LaTeX document using CPU and GPU: This is effectively the same question as if you would like to use another core (i.e. multi-core setup) for compiling the document, that's not possible. You want to use the GPU exclusively: I doubt that this would be highly effective as usually GPUs have ... 22 Make is Your Friend! This problem was solved ages ago, so let's take advantage of all the nice tools Unix gave us! The best solution I can think of for a large document is to simply not have any \begin{tikzpicture} or \tikz macros in it and do everything with \includepdf. To this end, I made a makefile (for GNU Make) that looks (and I do mean looks – ... 22 So, first let me say that this is probably the most thoroughly researched question I've read so far. Congratulations. I'll be reusing some of David's comments. The hashing algorithm takes the csname as an array of bytes (probably some differences there for XeTeX and LuaTeX, let me focus on 8-bit engines) and computes the sum of csname[i]*2^(len-i) % prime ... 18 General There are a few considerations when it comes to performance of TeX code: argument grabbing costs time, don't grab arguments unnecessarily \expandafter is slow, if you can work around it with the same amount of expansions it's faster, so instead of \if... \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi we'd use (this uses an ... 16 I'm a cofounder at writeLaTeX. We don't currently use a background daemon. Our backend uses pdflatex on Linux, so I can't say much about XeLaTeX on Windows (but XeLaTeX support is planned), but here's our experience. The main factor that determines the compile time for a small document is whether the many source files for the packages it uses are already ... 15 I believe the question "which is slower" depends on more than just the preamble. As you noted, it may make sense to postpone speed penalties until they are actually used. This answer is just a partial answer within my scope and interest, so you may need further input regarding the "factor 6 speed penalty" for your example preamble. In the following example,... 14 The respective TeX code is @<Compute the hash code |h|@>= h:=buffer[j]; for k:=j+1 to j+l-1 do begin h:=h+h+buffer[k]; while h>=hash_prime do h:=h-hash_prime; end So basically each digit gets mapped to some 2^k mod p. Prefixes and postfixes don't actually make the hashing worse, but the somewhat peculiar structure of the hash table means ... 14 The version without the braces is processed a tiny bit faster than the version with braces. Typesetting one million times$\frac12$required 8.69 seconds, while a million$\frac{1}{2}$took 8.81 seconds. This is what I call a negligible difference; the latter syntax is clearer. 13 The culprit for us turned out to be the case (insensitive) searching that has become the default for kpathsea in 2018. Thanks to @moewe for the pointer. The fix was to add to our texmf.cnf file: texmf_casefold_search = 0 After that, all of our pdftex jobs compiled at the speeds we were used to. 12 If you have a Windows system for some reason, font packages are way way slower than finding the actual fonts and installing them as native in the Fonts directory. Here, I've downloaded the OTF version from their website and used \directlua{starttime = os.clock()} \documentclass{article} \usepackage[timer=true]{regstats} \usepackage{polyglossia} \usepackage{... 11 You could compile everything in your document in draft mode except for the graphics by passing the draft option to your documentclass and then the final option, which is the inverse of draft to listings. \documentclass[draft]{scrartcl} \usepackage{graphicx} \usepackage[final]{listings} 11 If you know the table widths in advance you can "seed" the data that LT writes to the aux file so that it gets the correct widths first time, that won't speed up each run but means that it doesn't take several runs for LT to converge. (Basically look at the format of the command Lt writes to the aux file, recording the column widths, and put that into the ... 11 For comparison, in ConTeXt the penalty is similar. Test file (13 pages) \starttext \dorecurse{50}{\input knuth \par} \stoptext System details Macbook Pro with ConTeXt standalone. LuaTeX time context --noconsole --runs=1 test.tex 0.96s user 0.08s system 97% cpu 1.069 total LuaTeXJIT context --jit --noconsole --runs=1 test.tex 1.09s user 0.10s system ... 11 At the primitive level, TeX (other than LuaTeX) doesn't provide any support for floating point calculations. We have count and dimen registers which are (somewhat) convenient for implementing higher-level floating point code. The latter can look like floating points as the usual representation (in pt) does include a decimal part. However, these are actually ... 11 With expl3 you can use \tex_resettimer:D and \tex_elapsedtime:D, which exist for both pdfTeX and since TL 2019 for XeTeX (they are the primitives \(pdf)resettimer and \(pdf)elapsedtime renamed). For LuaTeX you can use the Lua functions from l3kernel. Most of this is a rudimentary version of what's in the l3benchmark package (see Joseph's answer), released ... 10 When you need to iterate on something (say, the formatting of an equation), a quick and dirty but very effective trick is to comment out the bulk of the document using: \iffalse all the stuff you don't need to compile every time... \fi then you can focus in on the particular section you are working on, until you've got it just right with a tight edit/... 10 The datatool package uses an insertion sort algorithm. The gory details, for anyone who's interested, are described in section 4.10 of the datatool documented code. However, I agree with the comments. TeX is a typesetting tool (and a very good one) but there are a lot of things that it's not, which is why datatool has an accompanying helper application ... 10 I highly recommend recompiling often. Here are some thoughts which were too long for a comment: You can see whether your code corresponds to what you wanted to achieve. You get compiler errors quite early and thus you can detect and resolve them more early and easily. When I code some more complex math formulas, I even compile while writing the formulas to ... 10 For all I know, there's no such macro in the LaTeX2e base (perhaps LaTeX3 has something equivalent?). But we can look up the definition of \testfeatureonce in the ConTeXt source code. The relevant definitions are in the syst-aux module. That implementation makes use of the eTeX primitives \pdfresettimer and \pdfelapsedtime to reset an internal timer and get ... 9 I use plain XeTeX†, so the externalization described in the TikZ manual doesn't work for me. But I've found a neat way to speed up my compilations. Like Andrew shows in his answer, I split the figures to their own .tex file, so that I have maindocument.tex and maindocument-figs.tex. Inside maindocument-figs.tex, I make sure the fonts, baselineskips, etc. ... 9 Personally, I use the -interaction=batchmode option to prevent verbose output. Also, for the first runs (except the last), you can use -draftmode option: -draftmode Sets \pdfdraftmode so pdfTeX doesn't write a PDF and doesn't read any included images, thus speeding up execution. In case of error ($? -ne 0), it is sufficient to tail the log file. ...

8

Use plain TeX One way to much faster compilations is to code in plain TeX, instead of LaTeX. Create your own format Another way is create your own format with only the commands you need. Abandon TikZ/Pgf in favour of MetaPost Furthermore, consider changing from TikZ/Pgf to MetaPost (and use LuaTeX). LuaTeX has the MetaPost library built-in. Compared to ...

Only top voted, non community-wiki answers of a minimum length are eligible