SPEEDTESTER: quick code speed test and comparison

版本 1.0.0.0 (2.1 KB) 作者: Sky Sartorius
A small utility for quickly testing code speed and making speed comparisons between different codes.
422.0 次下载
更新时间 2013/8/29

查看许可证

This small utility function often comes in handy for me, so I thought I'd share it in hopes someone else finds it useful.

SPEEDTESTER(f1,f2,f3,...) evaluates f() for function handle inputs or run(f) if input is a string and displays how long each evaluation took.

SPEEDTESTER(n,f1,f2,f3,...) evaluates each input n times and returns the total time for n evaluations of each.

SPEEDTESTER(n,p,f1,f2,f3,...) displays times to p decimal places.

t = SPEEDTESTER(f1,f2,...) returns time outputs in a vector.

Example included in help: Compare speeds for MAGIC function.
for i = 1:6; inputArgs{i} = sprintf('magic(%i)',100*i); end
inputArgs{2} = @() magic(200);
T = SPEEDTESTER(100,inputArgs{:});
plot(100:100:600,T*10,'o-k')
title('magic(x)'); xlabel('x'); ylabel('Mean eval time (ms)')

引用格式

Sky Sartorius (2024). SPEEDTESTER: quick code speed test and comparison (https://www.mathworks.com/matlabcentral/fileexchange/43250-speedtester-quick-code-speed-test-and-comparison), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Results, Reporting, and Test File Management 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0