Contents Previous Next Subchapters

Starting and Reading an Elapsed Timer
Syntax tic
See Also clock

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.

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.)
          X = rand(300, 300)
          X * X;