Contents Previous Next Subchapters

Starting and Reading an Elapsed Timer
Syntax tic
toc
See Also clock

Description
The function tic initialized the elapsed timer to zero. The function toc returns the number of seconds since the previous call to tic as a double-precision scalar.

Example
The following example displays how long in seconds it takes to multiply two 300 by 300 matrices. The begin and end commands are used to makes the elapsed time correspond to just execution and not compilation time. (Execution does not take place until the entire block is compiled.)
     begin
          X = rand(300, 300)
          tic
          X * X;
          toc
     end