I have a rather large LaTeX document in that it generates a lot of LaTeX code using lua (small .tex file on disk but large amount of generated LaTeX code). It is very slow to compile and takes about 1 hour to do so.
Almost all of the TeX code is generated from a few lua functions. At the moment I bypass most of the code until it is needed but I'm curious if there is some way to speed up the compilation process when rendering the full blown document.
Is there any way to profile the code and possibly speed it up? I'm not sure where the bottleneck is but essentially the (pseudo)code looks like this:
latex:
for i = 1, n {
\myluafunction{\arg{i}}
}
lua:
function myluafunction(arg) { ... tex.print(result) }
where myluafunction parses arg using lpeg then generates a lot of TikZ code using tex.print. The lua code is quite involved. While I haven't tried, I believe one can't use compiled lua code in lualatex, and even if so, I'm not sure how much of a difference it would make?
I imagine that the tex.print, even of a large amount of code, would be relatively fast?
Obviously there is a lot of geometry being rendered using TikZ. myluafunction essentially prints a bunch of LaTeX TikZ commands. Possibly TikZ is the issue here?
Any ideas what generally is the bottleneck and how it could potentially be improved? (would a virtual drive work for the .aux files, etc...)