minoki / cluttex

Process LaTeX documents without cluttering your working directory
GNU General Public License v3.0
45 stars 3 forks source link

[Question] Add benchmarking #9

Closed atticus-sullivan closed 2 years ago

atticus-sullivan commented 2 years ago

Hi, I'm currently writing some sort of benchmarking feature which enables the user to see which sections take long time to compile (it is open what to do with that information, but I find it interesting to know which parts take a long time (except for the preamble parsing/loading which hardly can be measured) the overall compilation time is high).

For that purpose, one would need to add this snippet to the preamble

\usepackage{l3benchmark}
\newwrite\benchmarkOutput
\immediate\openout\benchmarkOutput=\jobname.time
\ExplSyntaxOn
\AddToHook{cmd/section/before}{\benchmark_toc:\immediate\write\myoutput{\thesection \g_benchmark_time_fp}\benchmark_tic:}
\benchmark_tic:
\ExplSyntaxOff

(see l3benchmark.pdf for reference)

This creates a new file which holds the benchmarking results and the corresponding section number (which can be resolved by the use of the .aux file to the section name (this is done with a simple lua function called in the end which just parses the files)).

Does someone have an idea how to inject this into the input tex file? (I think the alternative would be to display information to the user what to add to the preamble if the time file is too old or not present)

PS: Sorry for asking the question as an issue, but I didn't found another way to get in touch.

atticus-sullivan commented 2 years ago

Thought about this for some time now. Seems this feature isn't that important (well yes after that one might know what parts of the document take much time compiling, but what to do about it? externalizing isn't that nicely, since it isn't flexible enough to allow for pagebreaking anywhere)