MATLAB: Asking about the effectiveness of the matlab code

computational burden

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.

Best Answer

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?