tic
Start stopwatch timer
Syntax
Description
tic
works with the toc
function to
measure elapsed time. The tic
function records the current
time, and the toc
function uses the recorded value to calculate
the elapsed time.
timerVal = tic
stores the current time in
timerVal
so that you can pass it explicitly to the
toc
function. Passing this value is useful when there are
multiple calls to tic
to time different parts of the same code.
timerVal
is an integer that has meaning only for the
toc
function.
Examples
Tips
Consecutive calls to the
tic
function overwrite the internally recorded starting time.The
clear
function does not reset the starting time recorded by atic
function call.Sometimes programs run too fast for
tic
andtoc
to provide useful data. If your code is faster than 1/10 second, consider measuring it running in a loop, and then average to find the time for a single run. For more information, see Measure the Performance of Your Code.The following actions result in unexpected output:
- Using
tic
andtoc
to timetimeit
- Using
tic
andtoc
within a function timed bytimeit
- Using
Extended Capabilities
Version History
Introduced before R2006a