1

I want to show how to measure time with sage, sagetex and the environment sagecommandline. Here is a minimal example:

\documentclass[a6paper,DIV=16]{scrartcl}
\pagestyle{empty}
\usepackage{sagetex}

% arara: lualatex % arara: sagetex % arara: lualatex

% !TEX encoding = UTF-8 Unicode % !TEX TS-program = sage

\begin{document} \begin{sagecommandline} sage: factorial(10) sage: %time factorial(10) sage: \percent time factorial(10) \end{sagecommandline} \end{document}

But neither %time nor \percent produce the desired output. Is it possible to include the output, which contains microseconds? On my machine e.g.: CPU times: user 11 µs, sys: 0 ns, total: 11 µs Wall time: 14.1 µs 3628800

  • You could put a \begingroup\catcode\%=12before your\begin{sagecommandline}and\endgroupafter\end{sagecommandline}`. – Skillmon Aug 30 '20 at 15:33
  • The mark-up gobbled up the forward tick before \% in my first comment. Did you try with the additional tick? – Skillmon Aug 30 '20 at 15:34
  • I tried it out, didn't work: ```\begin{document} \begingroup\catcode`%=12 \begin{sagecommandline} sage: factorial(10) sage: %time factorial(10) sage: \percent time factorial(10) \end{sagecommandline} \endgroup \end{document}
    
    
    – dantetante Aug 30 '20 at 15:37
  • Well, I never used sagetex nor do I have it on my machine... It was just a guess :) – Skillmon Aug 30 '20 at 16:03
  • In a Sage Cell Server you can use time(factorial(10)), which avoids the percent symbol. This doesn't work in sagetex. Apparently it doesn't know time and doesn't let you import it. However, timeit('factorial(10)') works in sagetex. Unfortunately it isn't printing out the mu. – DJP Aug 30 '20 at 16:55
  • Concerning the mu: did you use lualatex? It should be possible. I'll get back to this, unfortunately I don't have time for it this week. – dantetante Sep 01 '20 at 04:56
  • Error with pdflatex, warning with lualatex: "Package inputenc Warning: inputenc package ignored with utf8 based engines." – DJP Sep 01 '20 at 15:39

0 Answers0