Inconsistent tic and toc
2 views (last 30 days)
Show older comments
I see a smooth frame rate, but when I measure the frame rate with tic and toc I frequently see unrealistic measurements, like less than one frame per second. I would definitely notice such a frame drop. Below is an extreme example measuring the time for one frame to 16 seconds, but I never saw any stutter.
Can someone help me to ever trust tic toc again, please.
Excerpt from code (simplified)
tic
while j < 1000 && ~quit
aaa = toc;
disp(['Frame rate = ' num2str(1 / aaa)])
if 1 / aaa < 1
disp(aaa)
toc
end
tic
pause(.001)
j = j + 1;
PlotStuff(j)
if strcmp(KEY_EVENT.Key, 'q') % I use a WindowsKeyPress callback.
quit = 1;
end
end
Excerpt from output
Frame rate = 40.9828
Frame rate = 44.1438
Frame rate = 41.395
Frame rate = 30.4108
Frame rate = 29.6011
Frame rate = 40.0793
Frame rate = 32.4089
Frame rate = 42.4079
Frame rate = 0.061352
16.2994
Elapsed time is 16.299732 seconds.
Frame rate = 39.5448
Frame rate = 32.8217
Frame rate = 32.0156
Frame rate = 41.5176
0 Comments
Answers (1)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!