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
ticfunction overwrite the internally recorded starting time.The
clearfunction does not reset the starting time recorded by aticfunction call.Sometimes programs run too fast for
ticandtocto 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
ticandtocto timetimeit - Using
ticandtocwithin a function timed bytimeit
- Using
Extended Capabilities
Version History
Introduced before R2006a