Here the results of the gobble comparison. This tests runs the same command 1.000.000 times. It gobbles only empty arguments in this test. See also my comment below the question.
The results are:
Total times:
real 0m5.422s
user 0m5.360s
sys 0m0.050s
Results (in scaled seconds, 1/65536s)
\expandafter \@gobbletwo \@gobble : 95638
\expandafter \@gobble \@gobbletwo : 93726
\@gobbletwothenone : 56081
\@gobbleonethentwo : 57910
\@gobblethree : 45746
The \expandafter seems to require quite a bit of time.
If the three arguments are gobbled with two macros the order seems not significant. The \@gobblethree macro is the fastest.
When the to-be-gobbled arguments contain some actual text the time of reading this tokens takes more times than the gobbling of it, so all times are very close together.
Benchmark files:
\documentclass{minimal}
\makeatletter
\long\def\@gobblethree#1#2#3{}
\long\def\@gobbleonethentwo#1{\@gobbletwo}
\long\def\@gobbletwothenone#1#2{\@gobbleone}
\begin{document}
\input{a1}
\input{a2}
\input{a3}
\input{a4}
\input{a5}
\end{document}
The input files are:
% a1.tex
\def\name{\expandafter\@gobbletwo\@gobble}%
\@onelevel@sanitize\name
\pdfresettimer
\expandafter\@gobbletwo\@gobble{}{}{}%
% ...
\typeout{\name: \the\pdfelapsedtime}
% a2.tex
\def\name{\expandafter\@gobble\@gobbletwo}%
\@onelevel@sanitize\name
\pdfresettimer
\expandafter\@gobble\@gobbletwo{}{}{}%
% ...
\typeout{\name: \the\pdfelapsedtime}
% a3.tex
\def\name{\@gobbletwothenone}%
\@onelevel@sanitize\name
\pdfresettimer
\@gobbletwothenone{}{}{}%
% ...
\typeout{\name: \the\pdfelapsedtime}
% a4.tex
\def\name{\@gobbleonethentwo}%
\@onelevel@sanitize\name
\pdfresettimer
\@gobbleonethentwo{}{}{}%
% ...
\typeout{\name: \the\pdfelapsedtime}
% a5.tex
\def\name{\@gobblethree}%
\@onelevel@sanitize\name
\pdfresettimer
\@gobblethree{}{}{}%
% ...
\typeout{\name: \the\pdfelapsedtime}
\expandafter\@gobble\@gobbletwois faster then\@gobblethree. I would really like to know why this should be the case. Update: I made some benchmark which executes\expandafter\@gobble\@gobbletwo{}{}{}and\@gobblethree{}{}{}each 1.000.000 times and the results are: 88706 to 46309 scaled seconds (1/65536s). As you can see\@gobblethreeis almost twice as fast and both are so fast that they really do not need to be considered for speed optimizations. – Martin Scharrer Mar 11 '11 at 01:05\@gobblethreeis still faster. (That was the first time I compiled a 739 MB big.texfile :-) ) – Martin Scharrer Mar 11 '11 at 01:34\long\def\@gobblethree#1{\@gobbletwo}? I expect that this should be faster, since there is no\expandafter. – Bruno Le Floch Mar 11 '11 at 01:37tikz-timingwhich accumulates code in a macro so far. I compared it with a token register and writing the material into an external file. I will post the results later today. In short: Macro and token register are exponential-time because they have to copy the old material, with the token register faster (almost twice) and the file is of course linear-time. – Martin Scharrer Mar 11 '11 at 08:55filemodpackage. One of the sorting algorithm was exponential because of recursive expansion, until I linearized it with some tricky use of\csname. – Martin Scharrer Mar 11 '11 at 09:49:). --- Side comment: I discovered this week-end that it is possible to remove the last item of a list (sequence in LaTeX3) in a linear time. Now I only need to construct a linear-time conversion between comma-list and sequence. – Bruno Le Floch Mar 16 '11 at 17:20