13

I have an old and slow computer and long LaTeX files. When typing I prefer to use \frac 1{x} instead of \frac{1}{x} or x_i instead of x_{i}.

Does the presence or omission of curly braces in these instances affect the compilation time in any way? If so in which way?

Sergio Parreiras
  • 1,786
  • 1
  • 15
  • 32
  • 3
    Well to begin with, x_mn is not the same as x_{mn} but with regards to the compilation I cannot say much. – azetina Jan 21 '14 at 15:32
  • 3
    A simple experiment using time with and without braces for 60 simple expressions shows that the real and user times increase with braces (from 0.195s to 0.210s and from 0.176s to 0.188s). The sys time remains equal (0.020s). – Gonzalo Medina Jan 21 '14 at 15:36
  • 3
    I would guess the answer is "yes they do, but not by any appreciable amount". One way to test would be using the PGF benchmarking library. – Hammerite Jan 21 '14 at 15:36
  • 1
    You might speed up workflow (compiling, but also editing) by splitting your document into pieces to \import or \include. Then work on one piece at a time, with separate compilation, perhaps with \includeonly or commenting in/out lines in main.tex. – Ethan Bolker Jan 21 '14 at 15:39
  • @GonzaloMedina, what are real, user and sys? Where could I find more about? – Sigur Jan 21 '14 at 16:08
  • 2
  • 9
    The version without the braces are an (unreported) syntax error, so you shouldn't use those. The time differences are likely to be orders of magnitute less than the time taken to post the question:-) See http://tex.stackexchange.com/questions/82329/how-bad-for-tex-is-omitting-braces-even-if-the-result-is-the-same/82337#82337 – David Carlisle Jan 21 '14 at 16:30
  • 2
    Yes, but unless you are using a computer made before TeX was developed you won't notice any difference. – Martin Schröder Jan 23 '14 at 11:20
  • 9
    I tried typesetting $\frac12$ one million times getting a user time of 8.69 seconds, while $\frac{1}{2}$ the same number of times takes 8.81 seconds. This is what I call a negligible difference; the latter syntax is clearer. – egreg Jan 23 '14 at 11:37
  • @PaulGessler I did; if you upvote the answer now, it won't affect my rep. ;-) – egreg Jul 08 '14 at 19:33

1 Answers1

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.

egreg
  • 1,121,712