function out = mybench () bm_version = ['bm ', '0.1']; % Benchmark for matlab/octave. if (exist('OCTAVE_VERSION')) fprintf (' OCTAVE/Matlab benchmark version %s\n', bm_version); else fprintf (' Octave/MATLAB benchmark version %s\n', bm_version); end bm_numtests = 8; bm_targetaccuracy = 0.025; % target accuracy of mean of times bm_minrepetitions = 7; % min number of repetitions per test bm_maxtime = 60; % max runtime per test [seconds] bm_mintime = 0.3; % min runtime per test [seconds] bm_runtime = 3; % target runtime per test [seconds] % Reference times for vanilla Octave 2.0.16 on a PII 300MHz bm_reftime = [ 1.04 0.73 0.49 0.51 0.47 1.49 0.40 0.21]; bm_refname = 'Octave 2.0.16 on PII 300MHz'; if (exist('OCTAVE_VERSION')) fprintf (' Speed of octave %s on %s \n relative to %s\n', ... version, computer, bm_refname); fflush(stdout); else fprintf (' Speed of matlab %s on %s \n relative to %s\n', ... version, computer, bm_refname); end fprintf ('\n'); bm_mytime = zeros(1,bm_numtests); for f = 1:bm_numtests res = []; bm_test(f,1); % increase the RSS, load things rep = 1; % number of repetitions per run while (1) % we would need a do..while really [name,time] = bm_test(f,rep); % evaluate name and time if (time*rep > bm_mintime) % run for at least bm_mintime break; % found approximate time end rep = 2*rep; % approaching min run time end fprintf('%-40s', name); % print name if (exist('OCTAVE_VERSION')) fflush(stdout); end rep = round(bm_runtime/time); % no. of repetitions per run rep = max(1,rep); % slow machines need this for runs = 1:bm_maxtime/bm_runtime % do runs [name,time] = bm_test(f,rep); % run res(runs) = time; % store performance if (runs < bm_minrepetitions) % jump rest of for loop continue end res = sort(res); bm_mean = mean(res(2:runs-1)); % remove min and max results if (std(res)/bm_mean < bm_targetaccuracy) break end end % end of repetitions loop bm_mytime(f) = bm_mean; % print 95% confidence interval fprintf('%5.2f (%5.2f sec) +/- %.1f%% (%d runs)\n', ... bm_reftime(f)/bm_mean, bm_mean, 200*std(res)/bm_mean, runs*rep); if (exist('OCTAVE_VERSION')) fflush(stdout); end end clear bm_x % Display the geometric mean of the results fprintf('-- Performance index (%s): %.3g\n\n', bm_version, ... prod(bm_reftime./bm_mytime)^(1/length(bm_reftime))); endfunction