资源简介
matlab的功能函数,属于计时工具,
Copyright (c) 2010, The MathWorks, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
代码片段和文件信息
function [t measurement_overhead measurement_details] = timeit(f num_outputs)
%TIMEIT Measure time required to run function.
% T = TIMEIT(F) measures the time (in seconds) required to run F which is a
% function handle. TIMEIT calls F with either no output arguments or one
% output argument depending on nargout(F).
%
% T = TIMEIT(FN) calls F with N output arguments. N can be 0 1 2 3 or 4.
%
% TIMEIT handles automatically the usual benchmarking procedures of “warming
% up“ F figuring out how many times to repeat F in a timing loop etc.
% TIMEIT also compensates for the estimated time-measurement overhead
% associated with tic/toc and with calling function handles. TIMEIT returns
% the median of several repeated measurements.
%
% Examples
% --------
% How much time does it take to compute sum(A.‘ .* B 1) where A is
% 12000-by-400 and B is 400-by-12000?
%
% A = rand(12000 400);
% B = rand(400 12000);
% f = @() sum(A.‘ .* B 1);
% timeit(f)
%
% How much time does it take to call svd with three output arguments?
%
% X = [1 2; 3 4; 5 6; 7 8];
% f = @() svd(X);
% timeit(f 3)
%
% How much time does it take to dilate the text.png image with
% a 25-by-25 all-ones structuring element? (This example uses Image Processing
% Toolbox functions.)
%
% bw = imread(‘text.png‘);
% se = strel(ones(25 25));
% g = @() imdilate(bw se);
% timeit(g)
% Steve Eddins
% Copyright 2008-2010 The MathWorks Inc.
if nargin < 2
num_outputs = min(numOutputs(f) 1);
else
if num_outputs > 4
warning(‘MATLAB:timeit:tooManyOutputs‘ ...
‘Too many function output arguments specified. timeit will call your function with 4 output arguments.‘);
end
end
t_rough = roughEstimate(f num_outputs);
% Calculate the number of inner-loop repetitions so that the inner for-loop
% takes at least about 1ms to execute.
desired_inner_loop_time = 0.001;
num_inner_iterations = max(ceil(desired_inner_loop_time / t_rough) 1);
% Run the outer loop enough times to give a reasonable set of inputs to median.
num_outer_iterations = 11;
% If the estimated running time for the timing loops is too long
% reduce the number of outer loop iterations.
estimated_running_time = num_outer_iterations * num_inner_iterations * t_rough;
long_time = 15;
min_outer_iterations = 3;
if estimated_running_time > long_time
num_outer_iterations = ceil(long_time / (num_inner_iterations * t_rough));
num_outer_iterations = max(num_outer_iterations min_outer_iterations);
end
times = zeros(num_outer_iterations 1);
for k = 1:num_outer_iterations
% Coding note: An earlier version of this code constructed an “outputs“ cell
% array which was used in comma-separated form for the left-hand side of
% the call to f(). It turned out though that the comma-separated output
% argument
- 上一篇:直方图规格化
- 下一篇:max VR代理插件
相关资源
- 自己编写的matlab运动模糊盲复原程序
- LFM脉冲压缩matlab程序264292
- 异步电机直接转矩控制Matlab仿真
- CNN卷积神经网络的MATLAB程序解释
- 模糊K-均值算法及其matlab实现
- 基于MATLAB的_4_DQPSK信号差分解调性能仿
- 波束形成算法
- matlab can总线工具箱介绍
- matlab修正离轴制作全息图与再现
- Wagner Whitin算法的Matlab实现附有算例
- doa算法的matlab实现
- MATLAB中傅里叶变换常用函数
- matlab信噪比的计算
- 相控阵天线测试仿真
- matlab空间圆弧插补程序
- 小波变换图像去噪MATLAB仿真
- 圆阵目标方位估计,mvdr方法matlab
- 线性偏振片Mueller矩阵计算_Matlab代码
- 无约束最优控制matlab程序
- 回声抵消器
- 基于肤色的人脸检测matlab代码
- 详解MATLAB 数字信号处理[张德丰][程序
- 7,3循环码课程设计
- 卡尔曼滤波matlab代码
- GPS 捕获 matlab仿真实现
- Matlab最早版本
- 用MATLAB实现Bresenham方法画圆
- 智能优化算法及其MATLAB第2版-书中的
- 基于遗传算法的TSP问题(matlab)
- dipum_toolbox_2.0.1.zip数字图像处理课本自
评论
共有 条评论