matlab 计算程序运行时间 的几个函数

来源:互联网 发布:linux 网络io监控 编辑:程序博客网 时间:2024/05/02 02:49
 
MATLAB中测试程序运行时间的函数- [Matlab]1. profile
例子:
   profile on
       plot(magic(35))
       profile viewer
       profsave(profile('info'),'profile_results')
       profile on -history
       plot(magic(4));
       p = profile('info');
       for n = 1:size(p.FunctionHistory,2)
           if p.FunctionHistory(1,n)==0
               str = 'entering function: ';
           else
               str = ' exiting function: ';
           end
           disp([str p.FunctionTable(p.FunctionHistory(2,n)).FunctionName]);
       end
2. tic,toc
tic
 
operation
 
toc
 
3. cputime
t=cputime;
 
your_operation
 
cputime-t
 
4. clock,etime
t0 = clock;
operation
etime(clock,t0)
 
原创粉丝点击