Borrar filtros
Borrar filtros

Execution Time

133 visualizaciones (últimos 30 días)
sanjay Mohanty
sanjay Mohanty el 18 de Feb. de 2011
Comentada: Walter Roberson el 21 de Abr. de 2021
how to find the execution time of a matlab program.
  3 comentarios
Ijaz Ahmad
Ijaz Ahmad el 21 de Abr. de 2021
The best to do is to use the "Run and Time" in the "Editor" menu. It shows a complete summary of every function that has been called and the time it has taken.
Walter Roberson
Walter Roberson el 21 de Abr. de 2021
Run and Time changes the execution time, sometimes a fair amount.

Iniciar sesión para comentar.

Respuesta aceptada

Namrata
Namrata el 18 de Feb. de 2011
execution time can be found by tic-toc command.place tic; before the first line of code and toc; after the last line of the code
e.g.
tic;
MATLAB code
toc;
  5 comentarios
Dario gms
Dario gms el 16 de Nov. de 2020
The first time I read this i though it was a bad joke, nvm thank you
Bin Qi
Bin Qi el 3 de Feb. de 2021
It is a legit answer. Thank you.

Iniciar sesión para comentar.

Más respuestas (4)

Iain
Iain el 14 de Jun. de 2013
Its more powerful to use "now" to get the current time than tic & toc, but it takes a bit more effort.
  2 comentarios
Alexander Andreychenko
Alexander Andreychenko el 5 de Abr. de 2016
Are you aware of anything that allows folding of tic/toc ? I found that there are undocumented options for tic and toc but what I exactly want is the following:
tic
% doing something large
tic
function_1();
functionTime_1 = toc;
tic
function_2();
functionTime_2 = toc;
wholeTime = toc;
Currently, in this case I see functionTime_1 and functionTime_2 but I don't see the way to get wholeTime.
Walter Roberson
Walter Roberson el 5 de Abr. de 2016
now1 = tic();
function_1();
functionTime_1 = toc(now1);
now2 = tic();
function_2();
functionTime_2 = toc(now2);
wholeTime = toc(now1);

Iniciar sesión para comentar.


Mohd Sapiee
Mohd Sapiee el 4 de Dic. de 2018
Also it is very useful to know the time taken or elapsed in Matlab is reading data from an Excel file, especially for very large number of Excel cells.
tic;
xlsread( );
toc;

Oleg Komarov
Oleg Komarov el 18 de Feb. de 2011
Also, you can use the profiler
Oleg
  1 comentario
Anuj Patil
Anuj Patil el 6 de Jun. de 2018
Profiler will give compile+execution time,so not useful in most applications. timeit seems a good option.
Also you can manually use 'clock' function.

Iniciar sesión para comentar.


Royi Avital
Royi Avital el 18 de Feb. de 2011
I really like using TimeIt.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by