Set or check a wall-clock timer.
Calling tic
without an output argument sets the internal timer state.
Subsequent calls to toc
return the number of seconds since the timer
was set.
For example,
tic (); # many computations later… elapsed_time = toc ();
will set the variable elapsed_time
to the number of seconds since
the most recent call to the function tic
.
If called with one output argument, tic
returns a scalar
of type uint64
that may be later passed to toc
.
id = tic; pause (5); toc (id) ⇒ 5.0010
Calling tic
and toc
this way allows nested timing calls.
If you are more interested in the CPU time that your process used, you
should use the cputime
function instead. The tic
and
toc
functions report the actual wall clock time that elapsed
between the calls. This may include time spent processing other jobs or
doing nothing at all.
See also: toc, cputime.
Package: octave