CPU time used by MATLAB
t = cputime returns the total CPU time used by MATLAB® since it was started. The returned CPU time is expressed in seconds.
Each call to
cputime returns the total CPU time used by MATLAB up to the point when the function is called. To measure the CPU time used to
run your code, place two calls to
cputime before and after the code,
and then calculate the difference between the returned values.
Measure the CPU time used to run
tStart = cputime; surf(peaks(40))
tEnd = cputime - tStart
tEnd = 0.3400
For example, the CPU time for
pause is typically
tStart = cputime; pause(1) tEnd = cputime - tStart
tEnd = 0.1094
However, the wall-clock time accounts for the actual time that MATLAB execution is paused:
tic pause(1) toc
Elapsed time is 1.000483 seconds.
For more information, see Measure the Performance of Your Code.