Whether ADD SEMICOLON for output will reduce execution time?

If my code compute data for 1 day. If I ADD SEMICOLON after the statements, means nothing display in Command Windows, does this will reduce execution time greatly?

 Akzeptierte Antwort

Star Strider
Star Strider am 8 Mär. 2016

0 Stimmen

The only way to determine that quantitatively is to time it with and without the semicolons. Adding semicolons to suppress Command Window output would speed your code. You would have to define whether it speeds it ‘greatly’. For short routines, likely not much. For long or iterated routines, likely much.

4 Kommentare

Thanks.
Do you have paper or formal material to support this idea?
My pleasure.
Quantitatively, no. I’m not aware of any papers.
The difference varies with your code. There are several functions such as timeit, tic, toc, etime, and cputime that will allow you to time your code execution. The timeit function seems to be the most reliable, but is limited to functions. For timing script execution, I usually use tic, toc, and etime. The cputime function is likely the least reliable for the reasons stated in its documentation.
Great. Thank you for your detailed answer.
My pleasure.
When I first started using MATLAB 20+ years ago, etime was the only option, so I got used to using it. The tic and toc functions arrived later, and are preferable.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by