In the Matlab documentation for cputime
, it says:
Although it is possible to measure performance using the cputime function, it is recommended that you use the tic and toc functions for this purpose exclusively. It has been the general rule for CPU-intensive calculations run on Microsoft® Windows® machines that the elapsed time using cputime and the elapsed time using tic and toc are close in value, ignoring any first time costs. There are cases however that show a significant difference between these two methods. For example, in the case of a Pentium 4 with hyperthreading running Windows, there can be a significant difference between the values returned by cputime versus tic and toc.
I have an Intel Core i5 running linux. I want to measure the CPU time of a Matlab script. tic
and toc
return real time, which is affected by other processes running in the system. Should I use cputime
?
Note: In the documentation it also says that cputime
overflows and wraps around whenever it hits the internal representation limit. This doesn't affect me because I know that my program execution time is shorter than the internal representation limit.