\subsection{time}
\label{labtime}
\noindent Name: \textbf{time}\\
\phantom{aaa}procedure for timing \sollya code.\\[0.2cm]
\noindent Usage: 
\begin{center}
\textbf{time}(\emph{code}) : \textsf{code} $\rightarrow$ \textsf{constant}\\
\end{center}
Parameters: 
\begin{itemize}
\item \emph{code} is the code to be timed.
\end{itemize}
\noindent Description: \begin{itemize}

\item \textbf{time} permits timing a \sollya instruction, resp. a begin-end block
   of \sollya instructions. The timing value, measured in seconds, is returned
   as a \sollya constant (and not merely displayed as for \textbf{timing}). This 
   permits performing computations of the timing measurement value inside \sollya.

\item The extended \textbf{nop} command permits executing a defined number of
   useless instructions. Taking the ratio of the time needed to execute a
   certain \sollya instruction and the time for executing a \textbf{nop}
   therefore gives a way to abstract from the speed of a particular 
   machine when evaluating an algorithm's performance.
\end{itemize}
\noindent Example 1: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> t = time(p=remez(sin(x),10,[-1;1]));
> write(t,"s were spent computing p = ",p,"\n");
4.8366210999999999999999999999999999998902343311586e-2s were spent computing p =
 9.0486898749977990986908851357759191711354777014602e-17 * x^10 + 2.687625951151
23596299959320959141640012683406736586e-6 * x^9 + -2.424797849252131334907323228
9246205727856268698001e-16 * x^8 + -1.983448630209659297012456065035864612261309
37598776e-4 * x^7 + 2.2748214757753544349162426281857910162575492126267e-16 * x^
6 + 8.3333037186560980567697821420813799547276481409702e-3 * x^5 + -8.5747151989
72066974170696130354953131211051121887e-17 * x^4 + -0.16666666138601323707621656
6493953847771564552744173 * x^3 + 1.05699558969863875841493332282097022580493449
058156e-17 * x^2 + 0.99999999973628365676559825181776417246038944720795 * x + (-
3.1206530956601883024316320853642604562810646600878e-19)
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> write(time({ p=remez(sin(x),10,[-1;1]); write("The error is 2^(", log2(dirtyin
fnorm(p-sin(x),[-1;1])), ")\n"); }), " s were spent\n");
The error is 2^(log2(2.39601979446524486606649528289933482070294808074097e-11))
7.9472044000000000000000000000000000004018615329303e-2 s were spent
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 3: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> t = time(bashexecute("sleep 10"));
> write(~(t-10),"s of execution overhead.\n");
3.9814599999999999999999999999999994616717656646574e-3s of execution overhead.
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 4: 
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> ratio := time(p=remez(sin(x),10,[-1;1]))/time(nop(10));
> write("This ratio = ", ratio, " should somehow be independent of the type of m
achine.\n");
This ratio = 1.41568033301580390523445374661654986884071966148744 should somehow
 be independent of the type of machine.
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{timing} (\ref{labtiming}), \textbf{nop} (\ref{labnop})
