tc=cputoc
tc : | Elapsed cpu time in seconds |
tic; for i=10000000000; x=cos(pi/16); end; toc
cputic; for i=10000000000; x=cos(pi/16); end; cputoc
f=@() cos(pi/3), timeit(f)
This function, cputoc
, is part of the SolidGeometry library and is used to measure the elapsed CPU time since a previous call to cputic
. It is similar to the built-in toc
function but specifically uses the CPU timer.
The function does not take any input parameters.
ctic_tic
: A global variable that stores the CPU time at the moment cputic
was called. This is used as a reference point to calculate the elapsed CPU time.tc
: The elapsed CPU time in seconds since cputic
was called.ctic_tic
to retrieve the stored CPU time from the last cputic
call.ctic_tic
from the current CPU time obtained using cputime
.fprintf
.The function can be used in conjunction with cputic
to measure the CPU time taken by a block of code:
tic; for i=1:10000000000; x=cos(pi/16); end; toc cputic; for i=1:10000000000; x=cos(pi/16); end; cputoc f=@() cos(pi/3); timeit(f)
In this example, both toc
and cputoc
are used to measure the time taken by a loop, but cputoc
specifically measures the CPU time.