I develop some web applications which output their reports in LaTeX (I'm aware this is not very standard but "why" and "is it the best choice" do not want to be the point of this question, although they are interesting topics).

I'm fine with most of the tasks and problems involved, but I do hit performance issues on the server when using TikZ for complex graphics (charts, bars, pies and the sort).

The question is: does anyone has experience on performance of the different graphic packages? I've read this interesting post but, if possible, I would like to avoid to learn each of the alternatives, build the same page with all of them and measure the compiling time.

Thanks a lot for any answer/comment/hint

Edit: as of @cfr comment, here you are an example of one of the most complex applications

\draw[white] (-3.3,-0.2) rectangle  (3.3,3.3);
\fill [red] (0:0) -- ( 0:3) arc[start angle=0, delta angle=\startinganglery+\shadingangle/2]  -- cycle;
\fill [yellow] (0:0) -- (\startinganglery+\shadingangle/2:3) arc[start angle=\startinganglery+\shadingangle/2, delta angle=\startingangleyg-\startinganglery] -- cycle;
\fill [green] (0:0) -- (\startingangleyg+\shadingangle/2:3) arc[start angle=\startingangleyg+\shadingangle/2, delta angle=180-\startingangleyg-\shadingangle/2] -- cycle;

\foreach \i[evaluate={\col=(\i+.5)/\subdivisions*100}] in {0,...,\numexpr\subdivisions-1\relax}
        (0,0) -- (\i*\shadingangle/\subdivisions+\startinganglery:3) arc[start angle=\i*\shadingangle/\subdivisions+\startinganglery, end angle=(\i+1)*\shadingangle/\subdivisions+1+\startinganglery] -- cycle;
\foreach \i[evaluate={\col=(\i+.5)/\subdivisions*100}] in {0,...,\numexpr\subdivisions-1\relax}
        (0,0) -- (\i*\shadingangle/\subdivisions+\startingangleyg:3) arc[start angle=\i*\shadingangle/\subdivisions+\startingangleyg, end angle=(\i+1)*\shadingangle/\subdivisions+\startingangleyg] -- cycle;
\fill [white] (2.25,0) arc (0:180:2.25);
\draw (-3,0) -- (3,0);
\draw (3,0) arc  (0:180:3);

\draw [decorate,decoration={text along path, text=|\small|low medium high||,
text align=fit to path stretching spaces}]
(-3.1,0) arc  (180:0:3.1);

\fill (0.1,0) arc (0:180:0.1);
\draw [->,very thick] (0,0) -- (96:2.2);

\node[below,text width=6cm,align=center] at (0,0) {Compliance risk};
  • 3
    Welcome! Having an external programme produce the graphics would (probably) be faster depending on the type of content and complexity. Providing a minimal, but representative, example in the form of a small, compilable document would help. – cfr Feb 25 '16 at 13:46
  • @cfr I put an example in my post. About your suggestion: having an external program creating .png graphics could be an option, thanks. I'll definitely think about it, although that would mean rethink quite a bit my infrastructure. – dirluca Feb 25 '16 at 14:21

If you would choose TikZ, you could speed up the compilation by using


which forces TikZ to save and, if possible, reuse the pictures. Consequently, this would be (nearly) as fast as using external graphics. Of course, this works only if the pictures are not changed (very often).

  • This sounds wonderful. Does it decide by itself if the picture has changed? Or do I have to recognize the changed data and remove the appropriate files? (I guess there will be a way to detect which file refers to which graph) – dirluca Feb 25 '16 at 15:13
  • 1
    Yes, you don't have to check anything. It may be advantageous to use \tikzexternalize[prefix=tikz/], to set a folder for the temporary TikZ pictures. You can read more in the TikZ-PGF manual, search for Externalization Library (currently page 607). – Ondrian Feb 25 '16 at 15:17
  • 2
    I would not recommend this for a web application because it requires running with shell escape enabled @Ondrian. Unless you are absolutely certain you have some independent method of constraining things. – cfr Feb 25 '16 at 22:17
  • @cfr That's a very good point. I do have pieces of the document created directly by the user (mainly comments). I do validate everything, obviously, but from a php perspective and not from a LaTeX one! I do not want to be kown as the guy who invented the LaTeX injection :-) – dirluca Feb 26 '16 at 7:53
  • @cfr Ops, already existing copyright – dirluca Feb 26 '16 at 8:00

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.