Asking about the effectiveness of my matlab code

Hey guys, this could be really easy but I haven't figured it out.
How,
with a command given at the end of a code,
do I ask MATLAB
to print information
about the time and memory (or anything else) consumed
for the completion of this code?
Please help.
Thanks in advance for any answers.

 Réponse acceptée

Walter Roberson
Walter Roberson le 9 Nov 2011

0 votes

If you are restricted to not putting anything in your code, just measuring afterwards, then running your code as the first thing after starting MATLAB, and using cputime() afterwards, is the best you can do.
There is no way to calculate the amount of memory used.
Amount of memory used would need to be carefully defined: if I use a block of memory and give it back again and the block gets re-used, then should the block count? Should I be penalized memory costs because MATLAB does not like to do operations "in-place" and so tends to copy memory and alter the copy even when in theory the original locations could be updated? Should I be allowed to claim credit for lower memory use because MATLAB shares copies of arrays until you need to write to them?
On MS Windows, there is feature('memstats') that tells you something about the breakdown of current memory availability but doesn't tell you how much you "used". That feature() is not available on Linux or Mac OS-X.
MATLAB uses memory to store parsed versions of source files (for efficiency) and to build "Just In Time" (JIT) optimization. Should the memory for that be counted?

Plus de réponses (0)

Catégories

En savoir plus sur Scripts dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by