Start stopwatch timer
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.
Consecutive calls to the tic
function overwrite the
internally recorded starting time.
The clear
function does not reset
the starting time recorded by a tic
function call.
Sometimes programs run too fast for tic
and
toc
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:
tic
and toc
to time
timeit
tic
and toc
within a
function timed by timeit