Timeit on pause(2) returns weird ouput
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to get the timeit function to work.I read https://uk.mathworks.com/help/matlab/ref/timeit.html and get the example:
X = rand(100);
f = @() svd(X);
t1 = timeit(f)
I want to try this using the pause(2), since this should take about 2 seconds:
g = @() pause(2);
t2 = timeit(g)
the output is
t2 =
3.4639e-06
which is a lot less than the expected 2 seconds. Clearly I am missunderstanding something (which probably makes my more serious attempts at using timeit also wrong), but what?
0 comentarios
Respuestas (1)
Peter Perkins
el 2 de Mzo. de 2022
The issue is pause, not timeit:
"STATE = pause(...) returns the state of pause previous to processing the input arguments."
>> t2 = timeit(g,0)
t2 =
2.000208413333
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!