MATLAB measure a function run time
How to print the time of a function in MATLAB
example:
%%%TAKE TIME
A = [2 1 3 ; 开发者_如何转开发1 2 5 ;3 5 4 ]
[U,S,V] = svd(A)
%%%FINISH TIME
whats the syntax?
you can also use the nonsingleton forms of tic and toc:
tStart=tic;
A = [2 1 3 ; 1 2 5 ;3 5 4 ]
[U,S,V] = svd(A)
tElapsed=toc(tStart);
This allows the use of more than one timer. (otherwise you have to ensure exclusive use of tic
and toc
for one measurement)
tic()
A = [2 1 3 ; 1 2 5 ;3 5 4 ]
[U,S,V] = svd(A)
toc()
If there are many functions and assignments in your code you may use profile
function from matlab library. Before running m file write profile on to command window. After execution check each function's and children function's run time via profile report. You can acquire detailed explanation via help profile
.
精彩评论