tic, toc - Measure performance using stopwatch timer

Synopsis

tic
   any statements
toc
t = toc

Description

tic starts a stopwatch timer.

toc prints the elapsed time since tic was used.

t = toc returns the elapsed time in t.

Remarks

The tic and toc functions work together to measure elapsed time. tic saves the current time that toc uses later to measure the elapsed time. The sequence of commands

tic
operations
toc

measures the amount of time the MATLAB® software takes to complete one or more operations, and displays the time in seconds.

Examples

This example measures how the time required to solve a linear system varies with the order of a matrix.

for n = 1:100
    A = rand(n,n);
    b = rand(n,1);
    tic
    x = A\b;
    t(n) = toc;
end
plot(t)

See Also

clock, cputime, etime, profile

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS