diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex index 1043825d60f..ea1f469abe8 100644 --- a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryprofiler.code.tex @@ -20,9 +20,24 @@ %-------------------------------------------- \pgfutil@ifundefined{pdfelapsedtime}{% - \PackageError{pgf}{library 'profiler' can only be used with pdftex Rev. >= 1.671 because it needs the \string\pdfelapsedtime\space command}{}% - \global\let\pdfelapsedtime=\c@pgf@counta -}{} + % Ok, \pdfelapsedtime is not defined. + % Maybe we run luatex? + \pgfutil@ifluatex + % Yes. So we emulate the primitive by a macro. + % (see http://tex.stackexchange.com/q/32507/8425) + \def\pgfutil@pdfelapsedtime{% + \numexpr\pgfutil@directlua{% + tex.print(math.floor((os.clock())*65536+0.5))}\relax} + \else + % Raise an error + \pgferror{% + Library 'profiler' can only be used with pdftex Rev. >= 1.671 + because it needs the \string\pdfelapsedtime\space command or + with luatex}% + \global\let\pgfutil@pdfelapsedtime=\c@pgf@counta + \fi}{% + % We run pdftex. That's ok. + \let\pgfutil@pdfelapsedtime\pdfelapsedtime} % Defines a new profiler entry named `#1'. @@ -64,7 +79,7 @@ \def\pgfprofilenewforenvironment@[#1]#2{% \expandafter\pgfprofile@@to@pgfretval\pgfprofile@TeX@DIALECT@toenvironment@begin{#2}% \ifx\pgfretval\relax - \PackageError{pgf}{\string\pgfprofilenewforenvironment{#2} doesn't work: the environment `#2' is (not yet?) known or not known in this context}{}% + \pgferror{\string\pgfprofilenewforenvironment{#2} doesn't work: the environment `#2' is (not yet?) known or not known in this context}{}% \else \expandafter\global\expandafter\let\csname pgfprofile@orig@begin@#2\endcsname=\pgfretval \expandafter\pgfprofile@@to@pgfretval\pgfprofile@TeX@DIALECT@toenvironment@end{#2}% @@ -132,7 +147,7 @@ \or \pgfprofilenewforcommandpattern[#1]{#2}{##1##2##3##4##5##6##7}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}}% \else - \PackageError{pgf}{library 'profiler' can't replace control sequences with '#3' arguments automatically, sorry.}% + \pgferror{library 'profiler' can't replace control sequences with '#3' arguments automatically, sorry.}{}% \fi \fi }% @@ -155,7 +170,7 @@ \fi \fi \if\pgfprofile@known0% - \PackageError{pgf}{\string\pgfprofilenewforcommandpattern{\string#2} doesn't work: the command `\string#2' is (not yet?) known or not known in this context}{}% + \pgferror{\string\pgfprofilenewforcommandpattern{\string#2} doesn't work: the command `\string#2' is (not yet?) known or not known in this context}% \else \begingroup \pgfprofile@cs@to@name{#2}% @@ -189,7 +204,7 @@ \def\pgfprofileshowinvocationsfor#1{% \pgfutil@ifundefined{b@pgfprofile@show@#1}{% - \PackageError{pgf}{\string\pgfprofileshowinvocationsfor{#1} doesn't work: the argument is no profiler entry}{}% + \pgferror{\string\pgfprofileshowinvocationsfor{#1} doesn't work: the argument is no profiler entry}% }{% \expandafter\gdef\csname b@pgfprofile@show@#1\endcsname{1}% \expandafter\gdef\csname b@pgfprofile@show@edef@#1\endcsname{0}% @@ -197,7 +212,7 @@ }% \def\pgfprofileshowinvocationsexpandedfor#1{% \pgfutil@ifundefined{b@pgfprofile@show@#1}{% - \PackageError{pgf}{\string\pgfprofileshowinvocationsfor{#1} doesn't work: the argument is no profiler entry}{}% + \pgferror{\string\pgfprofileshowinvocationsfor{#1} doesn't work: the argument is no profiler entry}% }{% \expandafter\gdef\csname b@pgfprofile@show@#1\endcsname{1}% \expandafter\gdef\csname b@pgfprofile@show@edef@#1\endcsname{1}% @@ -290,7 +305,7 @@ \pgfprofileifisrunning{#1}{% \relax }{% - \expandafter\xdef\csname c@pgfprofile@elapsed@at@start@#1\endcsname{\the\pdfelapsedtime}% + \expandafter\xdef\csname c@pgfprofile@elapsed@at@start@#1\endcsname{\the\pgfutil@pdfelapsedtime}% \expandafter\gdef\csname c@pgfprofile@subtractforself@#1\endcsname{0}% \pgfprofile@advance{c@pgfprofile@numinvocations@#1}{1}% \pgfprofilestackpush{#1}% @@ -305,7 +320,7 @@ \relax }{% \begingroup - \c@pgf@countb=\pdfelapsedtime\relax + \c@pgf@countb=\pgfutil@pdfelapsedtime\relax \advance\c@pgf@countb by-\csname c@pgfprofile@elapsed@at@start@#1\endcsname\relax % \pgfprofilestackpop\pgfretval |