Skip to content

Instantly share code, notes, and snippets.

@alphaville
Created February 1, 2013 15:15
Show Gist options
  • Select an option

  • Save alphaville/4691899 to your computer and use it in GitHub Desktop.

Select an option

Save alphaville/4691899 to your computer and use it in GitHub Desktop.
Measures the execution time of a MATLAB function (on average). Uses a fixed test time.
time_test = 4; % Time each test may last (in seconds)
tic;
t1=0;
ntrials=0;
while (t1<time_test)
% Do things to be benchmarked
ntrials=ntrials+1;
t1=toc;
end
time_coder=t1/ntrials;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment